﻿# Aider test commands turn nonzero exits into repair feedback

Configure Aider tests with a meaningful command exit status, useful failure output and explicit automatic-test settings so the repair loop receives the right evidence.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/guide-aider-test-exit-feedback/
Language: en

## Make the command express the check

Aider cannot infer a failed assertion from a command that reports success. Before adding automatic tests, choose a command that exercises the changed behavior and exits unsuccessfully when that behavior is wrong. Keep the invocation reproducible in the project's actual environment. A missing dependency or incorrect working directory is different evidence from a regression in the edited function.

## Read the test invocation contract

The [linting and testing guide](https://aider.chat/docs/usage/lint-test.html) says `/test` runs the supplied command without appending arguments. Required test selectors or configuration therefore belong in that command or its wrapper. The command should print diagnostic information to standard output or error and return a nonzero status on failure. A wrapper that catches every exception and exits successfully can prevent the assistant from receiving the feedback needed to investigate.

## Distinguish tests from general command output

The [command reference](https://aider.chat/docs/usage/commands.html) describes `/test` as adding output to chat on a nonzero exit; `/run` can optionally add a command's output. These interfaces support different conversations. Use a failing test to provide repair evidence, and retain the check's actual meaning rather than treating every printed warning as a failing assertion. A successful command does not establish coverage of a branch that the chosen tests never executed.

## Enable repetition deliberately

The [options reference](https://aider.chat/docs/config/options.html) separates `--test-cmd` from `--auto-test`, which is disabled by default. Configuring a command alone should not be described as proof that it runs after every edit. There is also a separate test-and-exit option. Record the selected workflow and inspect the effective settings when a session behaves differently from an example. Choose a bounded, relevant check before scheduling it into the edit loop.

## Verify the feedback and the repaired behavior

Use an authorized sample change with an observable failing case, inspect the diagnostic Aider receives, and compare the final behavior against the original requirement. The [task-contract guide](/journal/learn-codex-task-contract/) helps define that requirement, while [tool observations](/journal/learn-codex-tool-observation/) separate command execution from successful repair. Review the diff as well as the final test result: making a test pass by weakening its assertion does not satisfy the intended behavior.
