0Pricing
Zig Academy · Lesson

Build Steps and zig build run

Wire up named steps to invoke.

Build Steps and zig build run is a free Zig Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Zig Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Steps Are Named Tasks

A build can do more than compile. A step is a named task you trigger, like running the app or executing tests. 🪜

The Default Step

Running plain zig build executes the default install step, which compiles and copies your installed artifacts into zig-out.

zig build

Make a Run Artifact

To run your exe through the build, create a run command with addRunArtifact. It knows how to launch the binary you built.

const run_cmd = b.addRunArtifact(exe);

Run After Install

Make the run depend on the install step with step.dependOn so the latest binary is in place before it launches.

run_cmd.step.dependOn(b.getInstallStep());

Expose a Named Step

Give users a friendly name with b.step. The first argument is the name they type, the second is its description.

const run_step = b.step("run", "Run the app");

Wire the Step

Attach the run command to that named step so triggering it actually performs the work. Now the name run means something.

run_step.dependOn(&run_cmd.step);

Invoke It

With the step wired, zig build run builds the app and immediately runs it. One command goes from source to output.

zig build run

Pass Arguments Through

Forward command-line args to your program with addArgs, reading them from b.args after a double dash on the command line.

if (b.args) |args| run_cmd.addArgs(args);

Args After Dash Dash

Anything after -- is handed to your app, not to Zig, so zig build run -- hello passes hello to your program.

zig build run -- hello world

List Available Steps

Forgot the names? Run zig build --help to see every step you declared with b.step plus its description.

zig build --help

Steps Form a Tree

Each step depends on others, so triggering one runs its whole dependency chain in the right order, only rebuilding what changed. ✅

Quick Check

Recall how the name run becomes a usable command.

Recap

You wired a run step: addRunArtifact, depend on install, name it with b.step, and forward b.args so zig build run launches your app. 🎯

Frequently asked questions

Is the “Build Steps and zig build run” lesson free?

Yes — the full text of “Build Steps and zig build run” is free to read here on the web, and the Zig Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Zig Academy course, upgrade to CoddyKit PRO.

What will I learn in “Build Steps and zig build run”?

Wire up named steps to invoke. You practise Zig Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Zig Academy?

No prior experience is required. Zig Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Build Steps and zig build run” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Zig Academy lesson?

Yes. Every Zig Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Anatomy of a build.zig File
  2. Declaring Executables and Libraries
  3. Build Steps and zig build run
  4. Build Options and Flags
← Back to Zig Academy