Skip to content

Pattern reference

Every step receives a StepContext with these properties:

PropertyTypeDescription
$zx shellShell executor for running commands
logLoggerStructured logger (info, warn, error, debug)
envRecord<string, string|undefined>Environment variables
setEnv()(key, value) => voidSet an env var visible to this step and all subsequent steps
addPath()(dir) => voidPrepend a directory to PATH for this and all subsequent steps
inputsRecord<string, unknown>Typed inputs from dependency outputs
workflow{ name: string }Current workflow metadata
job{ name: string, runsOn: string }Current job metadata
matrixMatrixValues | undefinedMatrix values for current job instance
setSecretOutput()(key, value) => voidPublish an encrypted secret output consumable by downstream jobs

Steps can declare typed outputs using Zod schemas:

import { step } from '@kici-dev/sdk';
import { z } from 'zod';
const build = step('build', {
outputs: {
version: z.string(),
artifacts: z.array(z.string()),
},
run: async ({ $ }) => {
await $`pnpm build`;
return {
version: '1.0.0',
artifacts: ['dist/main.js', 'dist/styles.css'],
};
},
});

For more runnable examples, see the examples/ directory in the KiCI repository.

When workflows run via GitHub pull requests or pushes, KiCI creates GitHub Check runs that show detailed execution feedback directly in the GitHub UI.

  • Live progress: As steps execute, the check run updates with a checklist showing which steps are running, completed, or pending
  • Step durations: Each step shows its execution time (e.g., “Install deps (1.2s)”)
  • Failure details: When a step fails, the check run includes the error message, exit code, and the last 20 lines of log output
  • Source annotations: Failed steps are annotated directly on your workflow file (.kici/workflows/*.ts) in the GitHub PR diff, linking the failure to the exact step() call that failed

KiCI captures the source location of each step() call during compilation and stores it in the lock file. When a step fails, GitHub displays an annotation on the corresponding line in your workflow file:

// This step's source location is captured automatically
step('run tests', async ({ $ }) => {
await $`pnpm test`; // If this fails, GitHub annotates this step() call
});

To enable source location annotations, recompile your workflows after updating KiCI. The compiler captures step locations starting from compile schema version 2.

Terminal window
pnpm kici compile # Regenerates kici.lock.json with source locations