CircleCI Cheat Sheet
Practical CircleCI cheat sheet with setup steps, core workflows, debugging, and copy-paste examples.
circleci ci-cd pipelines automation infrastructure
CircleCI cheat sheet with real commands and snippets for setup, core workflows, debugging, and production-safe automation patterns. If you are working across tools, pair this with the Git Cheat Sheet and Docker Cheat Sheet.
Setup and Installation
Goal: Verify installation and CLI metadata
# Resolve command path from current shell
command -v circleci
# Print installed version to confirm runtime
circleci --version
# Read top-level help before using subcommands
circleci --help
Goal: Install or upgrade the tool on a workstation
# Install CircleCI CLI for local config validation
brew install circleci
# Verify CircleCI CLI version
circleci version
Goal: Run day-to-day commands
# Validate CircleCI config file
circleci config validate -c .circleci/config.yml
# Run local job execution
circleci local execute --job build
# Pack reusable config fragments
circleci config pack .circleci/src > .circleci/config.yml
# Process config with pipeline params
circleci config process .circleci/config.yml
Core Workflows
Goal: Capture command help for quick offline lookup
# Create docs folder for generated command references
mkdir -p docs/cli
# Write help output to a timestamped file
circleci --help > docs/cli/circleci-help.txt
# Search help output for a keyword
rg "config|auth|deploy" docs/cli/circleci-help.txt
Goal: Wrap repetitive commands in a script
# Create scripts directory for local automation
mkdir -p scripts
# Write repeatable health-check script
cat > scripts/check-circleci.sh <<'SH'
#!/usr/bin/env bash
set -euo pipefail
circleci --version
circleci --help >/dev/null
SH
# Make script executable and run it
chmod +x scripts/check-circleci.sh && ./scripts/check-circleci.sh
Configuration and Environment
Goal: Pin environment variables for predictable runs
# Define environment profile for local commands
export CIRCLECI_PROFILE=dev
# Persist profile in local shell configuration
echo 'export CIRCLECI_PROFILE=dev' >> ~/.zshrc
# Reload shell profile changes
source ~/.zshrc
Automation and CI
Goal: Define a working CI pipeline file
version: 2.1
jobs:
build:
docker:
- image: cimg/node:22.0
steps:
- checkout
- run: npm ci
- run: npm run check
- run: npm run build
workflows:
ci:
jobs:
- build
Goal: Add tool checks to CI pipeline
# Run lint/test/build in strict mode
set -euo pipefail
# Verify CLI exists before invoking workflow
command -v circleci
# Exit quickly if command is unavailable
circleci --version
Debugging and Troubleshooting
Goal: Collect diagnostics when commands fail
# Capture command output and exit code
circleci --help > /tmp/circleci-debug.log 2>&1; echo $?
# Inspect captured diagnostics
tail -n 80 /tmp/circleci-debug.log
# Check current shell PATH entries
echo $PATH | tr ':' '\n'
Common Gotchas
- Pin CircleCI versions in CI so local and pipeline behavior match.
- Check tool authentication context before running write or deploy commands.
- Prefer non-interactive flags in scripts to avoid stalled jobs.
- Capture stderr logs in CI artifacts for faster incident triage.
- Keep secrets in environment variables, not committed scripts.
Related Sheets
- Git Cheat Sheet — daily Git commands and production-ready examples.
- Docker Cheat Sheet — container build, run, and image lifecycle workflows.
- Jest Cheat Sheet — daily Jest commands and production-ready examples.
Related Cheat Sheets
Git Cheat Sheet
Practical Git cheat sheet with setup steps, core workflows, debugging, and copy-paste examples.
Docker Cheat Sheet
Practical Docker cheat sheet with setup steps, core workflows, debugging, and copy-paste examples.
Jest Cheat Sheet
Practical Jest cheat sheet with setup steps, core workflows, debugging, and copy-paste examples.