CLIO Coder
All tutorials

Scientific software5 min read

A numerical change, checked with CLIO Coder

Follow a temperature-conversion example through a floating-point test failure, a correction, and recorded verification.

Written for
v0.8.0
Works in
Terminal · Desktop alpha
Basis
Recorded session
Updated
Terminal View dock with the session's records on the left and the checked test row selected; the preview shows check test, its working directory examples/temperature-calibration, exit 0, the test command, and the passing test lines.
/view: the recorded check, with its working directory, exit status and output. Terminal · v0.8.0
On this pageBefore you start Open the example Check the numerical boundaries Run a declared check Inspect the recorded result

A small numerical task makes it easy to follow a change from code to a recorded check. This example converts temperatures between Celsius, Kelvin, and Fahrenheit, validates inputs, and tests physical boundaries without adding dependencies.

Before you start

  • CLIO Coder installed, with a connected model that supports tool calling.
  • Node.js 18.1 or newer and npm on your PATH. The installer's private Node.js is not added to PATH, so install them yourself.
  • The example archive below, extracted into a project you can open.

Open the example

Download the runnable temperature-calibration example. It includes the actual implementation, seven tests, and a private package manifest. It uses only the built-in Node.js test runner and has no dependencies.

Extract the archive into your project's examples/ folder, so the files live in examples/temperature-calibration/. Open the project in the terminal:

Shell

clio-coder

Select a model that supports tool calling. You can also use the desktop alpha with clio-coder gui --open. To reproduce the authoring task in your own project, ask:

Create four temperature conversion functions for Celsius, Kelvin, and Fahrenheit. Reject non-numeric and non-finite inputs with TypeError, and temperatures below absolute zero with RangeError. Use 273.15 for the Celsius/Kelvin offset. Add Node.js tests for freezing, boiling, absolute zero, round trips within 1e-10, and invalid inputs. Use no dependencies. Run the tests and report the actual result.

Choose a new example directory when creating files. In the supplied example, the implementation and tests are already present; start by asking CLIO Coder to read them.

Check the numerical boundaries

These reference temperatures cover ordinary values and the physical lower boundary:

Reference Celsius Kelvin Fahrenheit
Freezing point 0 °C 273.15 K 32 °F
Boiling point 100 °C 373.15 K 212 °F
Absolute zero −273.15 °C 0 K −459.67 °F

When CLIO Coder first wrote this example, the first run exposed an exact-equality assertion for the Fahrenheit value at absolute zero. JavaScript produced −459.66999999999996; the test expected −459.67. The agent changed that assertion to an absolute tolerance of 1e-10 and reran the tests. Review a tolerance against your domain’s numerical requirements before applying it elsewhere.

Run a declared check

The example’s private package.json declares its test command. With the archive extracted into the folder above, ask CLIO Coder:

Use verify with check test and cwd examples/temperature-calibration, then show the reference temperatures from examples/temperature-calibration/calibration.test.mjs as a table. Do not edit files.

If an approval card appears, read the command before allowing it. In the recorded run, the check exited 0 with seven passing tests, and CLIO Coder read the test file for the table. Naming the file keeps a fast model from searching the project for it.

CLIO Coder in the terminal running the declared test check through verify with exit 0, then showing the reference temperatures from the test file as a table

To run the same tests yourself from the repository root:

Shell

node --test examples/temperature-calibration/calibration.test.mjs

Inspect the recorded result

In the terminal, open /view and select the checked test row. The preview shows the check, its working directory, the exit status, and the output, so you can compare the answer with what ran. On the desktop alpha, Artifacts in the Session column lists the same record.

Terminal View dock with the session's records on the left and the checked test row selected; the preview shows check test, its working directory examples/temperature-calibration, exit 0, the test command, and the passing test lines.
/view: the recorded check, with its working directory, exit status and output. Terminal · v0.8.0

Passing tests establish the behavior covered by those tests. This small example does not establish the scientific validity of a larger application. For project-specific requirements, see quality policies and tool usage.

By The CLIO Coder team · CLIO Coder

Continue with the documentation