Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

CLI No Run Mode: Evidence an Agent Won't Execute

· 5 min read · Home Tech

In this article
  1. What "No Run Mode" Means
  2. How No Run Mode Works
  3. Evidence an Agent Won't Execute
  4. Common Misconceptions
  5. How to Verify No Run Mode
  6. When to Use No Run Mode
  7. Alternatives and Limitations
  8. Frequently Asked Questions

When a command-line interface (CLI) tool is invoked in "no run" mode (often called dry-run, check, or validate), the evidence that an agent will not execute is the absence of any state-changing side effects, combined with an explicit exit code and output indicating a simulated pass or failure. This is typically verified by the tool's documentation and by observing that no files are created, modified, or deleted, and no external systems are contacted.

What "No Run Mode" Means

No run mode is a safety feature built into many CLI tools, especially those that deploy infrastructure, modify files, or manage system state. When you pass a flag like --dry-run, --check, or --no-run, the tool parses your input, evaluates what it would do, and then stops short of actually doing it. The output is a plan or a report, not a change.

This mode is distinct from a simple help flag (-h) or a version flag (-v), which only print information and exit. No run mode performs the full logic of the operation, but with the final write, delete, or network call suppressed.

How No Run Mode Works

The implementation varies by tool, but the core principle is a conditional check before any mutating function. A typical flow:

  1. Parse arguments and load configuration.
  2. Build an execution plan (e.g., list of files to copy, resources to create).
  3. If no run mode is active, print the plan and skip the actual execution.
  4. Exit with a status code indicating success (0) or failure (non-zero) based on whether the plan was valid.

For example, terraform plan shows you what resources will be created, changed, or destroyed, but does not apply them. rsync --dry-run lists the files it would transfer without transferring. kubectl apply --dry-run=client validates a manifest against the client-side schema without contacting the server.

Evidence an Agent Won't Execute

If you are asking whether an agent (a script, a CI job, or an automated process) will execute in no run mode, the evidence is both direct and indirect.

  • Direct evidence: The tool's own documentation states that no run mode performs no changes. For instance, the man page for rsync says dry-run "makes no changes."
  • Observable evidence: Run the command and check the file system, database, or network logs. If no new files appear, no records are updated, and no outbound connections are made, the agent did not execute.
  • Exit code evidence: Many tools return a non-zero exit code in no run mode if the plan would fail, but they still do not perform any changes. A zero exit code means the plan is valid, not that changes were made.

Common Misconceptions

A frequent misunderstanding is that no run mode is a simulation that might accidentally leak a change. In well-designed tools, the code path for no run mode is separate from the execution path. However, there are edge cases:

  • Hooks and scripts: Some tools allow pre/post hooks that run even in dry-run mode. For example, a package manager might run a post-install script that creates a log file, even if the package itself is not installed.
  • Cache and lock files: Some tools write temporary cache or lock files even in no run mode. This is a change, but not the intended change.
  • Network calls for validation: A tool might make a read-only API call to validate credentials or fetch current state. This is not an execution, but it is a side effect.

To be certain, read the tool's documentation and test in a sandbox environment.

How to Verify No Run Mode

If you are writing or auditing an agent, you can verify that no run mode prevents execution by:

  1. Creating a test directory with known files.
  2. Running the tool in no run mode targeting that directory.
  3. Checking the directory contents before and after (e.g., find . -type f or a checksum).
  4. Monitoring network traffic with a tool like tcpdump or a proxy.
  5. Reviewing the tool's source code if it is open source.

When to Use No Run Mode

No run mode is ideal for:

  • CI/CD pipelines: Validate that a deployment plan is correct before applying it.
  • Scripting: Test a complex command without affecting your system.
  • Learning: See what a tool like git clean -n would remove before actually removing it.

It is not a substitute for a full test environment, because it does not catch runtime errors that only occur during actual execution.

Alternatives and Limitations

No run mode is not the only way to prevent execution. Alternatives include:

  • Sandboxing: Run the agent in a container or VM with no network access.
  • Permissions: Run as a user with read-only access to the target resources.
  • Audit mode: Some tools have a separate audit mode that logs actions without performing them.

Limitations of no run mode include: it may not catch all errors (e.g., a file that becomes read-only between plan and execution), it can be slower because it still computes the full plan, and it may not support every subcommand (some flags are ignored in dry-run).

Frequently Asked Questions

Does no run mode ever execute anything?

Generally no, but check for side effects like temporary files or network validation calls. The tool's documentation is the definitive source.

What exit code does no run mode return?

It returns the same exit code as a real run would, based on whether the plan is valid. Zero means the plan is valid, non-zero means it would fail.

Can no run mode be bypassed?

If the tool has a bug or if a hook script is misconfigured, a change might slip through. Always test in a safe environment.

Is no run mode the same as a simulation?

It is a form of simulation, but it only simulates the tool's own actions. It does not simulate the environment's response (e.g., a server might reject a request later).

How do I know if a tool supports no run mode?

Check the help output (--help) for flags like --dry-run, --check, or --no-run. The manual page or online docs will also list it.