Skip to main content

commands-workflows

commands-workflows provides cmdw, a command workflow manager for developers who want to turn recurring terminal routines into reliable, reusable workflows.

Use it to standardize project setup, testing, releases, deployments, API calls, maintenance tasks, and other command sequences that need structure without requiring a full automation platform. Workflows can include multiple commands, reusable placeholders, default values, global variables, file references, and list expansion.

Installation

pip install commands-workflows

After installation, run:

cmdw --help

Quick Start

Create a workflow:

cmdw create deploy \
  "git checkout {{branch=main}}" \
  "git pull" \
  "npm run build" \
  "npm run deploy -- --target {{target}}" \
  --desc "Build and deploy a project"

Run it with a required value:

cmdw run deploy production

Override a value by name:

cmdw run deploy --set target=staging --set branch=release

Show the saved workflow and the placeholders it expects:

cmdw show deploy

Core Concepts

Workflows

A workflow is a named list of shell commands. Commands run in the order they were saved.

cmdw create test "python -m unittest" --desc "Run the test suite"
cmdw run test

Useful commands:

cmdw list
cmdw show test
cmdw edit test --desc "Run all unit tests"
cmdw delete test

You can also use the long command names:

cmdw list-workflow
cmdw show-workflow test
cmdw run-workflow test

Placeholders

Use placeholders inside commands with {{name}}.

cmdw create greet "echo Hello {{name}}"
cmdw run greet Steven

Placeholders can have default values:

cmdw create branch "git checkout {{branch=main}}"
cmdw run branch
cmdw run branch develop

When a workflow has multiple placeholders, positional values are assigned in the order the placeholders appear:

cmdw create release "git tag v{{version}}" "git push origin v{{version}}"
cmdw run release 1.2.0

Use an explicit index when you want to control the positional order:

cmdw create api-call \
  "curl https://api.example.com/{{resource:1}}/{{id:2}}"

cmdw run api-call users 42

Named values passed with --set name=value override positional values:

cmdw run api-call --set resource=users --set id=42

Global Variables

Global variables let you keep shared values outside a single workflow. They are stored locally and can be reused by any workflow.

cmdw add-var account_id 123456
cmdw add-var env.production_url https://example.com
cmdw list-var

Reference them in commands:

cmdw create open-prod "curl {{global.env.production_url}}/health"
cmdw run open-prod

Nested variables are supported with dot notation:

cmdw edit-var env.production_url https://api.example.com
cmdw delete-var env.production_url

If your globals.json contains a key with dots, quote that segment inside the reference:

cmdw create dns "curl zones/global.cloudflare.zones.'{{domain}}'/dns_records"
cmdw run dns example.com

You can also wrap global references in percent signs when that makes a command easier to read:

cmdw create dns "curl zones/%global.cloudflare.zones.'{{domain}}'%/dns_records"

File and Script References

cmdw can resolve local file and helper script references at run time.

Use sys. to read a file:

cmdw create print-config "cat {{sys./path/to/config.json}}"

Use sys.ssh. to read from ~/.ssh:

cmdw create show-key "cat {{sys.ssh.id_rsa.pub}}"

Use scripts. to reference a file in ~/.cmdw/scripts:

cmdw create fetch "python {{scripts.fetch_data.py}}"

Use %...% syntax when a direct token is easier to place inside a command:

cmdw create fetch "python %scripts.fetch_data.py%"

List Expansion

A placeholder ending in [] expands a command once per value.

cmdw create ping-all "ping -c 1 {{host[]}}"
cmdw run ping-all --set "host[]=api.example.com,db.example.com"

List values can also come from global variables when the list reference is used as a default value:

cmdw add-var hosts "['api.example.com', 'db.example.com']"
cmdw create ping-hosts "ping -c 1 {{host[]=global.hosts}}"
cmdw run ping-hosts

Error Handling

By default, a workflow stops when a command fails.

Continue after failed commands:

cmdw run deploy production --continue-on-error

Reduce output:

cmdw run deploy production --mute

Command Reference

Command Description
cmdw create NAME [COMMANDS]... --desc TEXT Create a workflow.
cmdw list List saved workflows.
cmdw show NAME Show workflow commands and placeholders.
cmdw run NAME [ARGS]... Run a workflow.
cmdw run NAME --set key=value Run with named placeholder values.
cmdw edit NAME --new-name NAME Rename a workflow.
cmdw edit NAME --desc TEXT Update a workflow description.
cmdw edit NAME --command TEXT Replace workflow commands. Repeat for multiple commands.
cmdw delete NAME Delete a workflow.
cmdw add-var NAME VALUE Add a global variable.
cmdw edit-var NAME VALUE Update a global variable.
cmdw delete-var NAME Delete a global variable.
cmdw list-var List global variables.

Local Storage

cmdw stores data in your home directory:

~/.cmdw/workflows.json
~/.cmdw/globals.json
~/.cmdw/scripts/

The files are local JSON files. You can back them up, inspect them, or sync them with your own tooling.

Practical Examples

Run a Project Setup Sequence

cmdw create setup \
  "python -m venv .venv" \
  "pip install -r requirements.txt" \
  "python -m unittest" \
  --desc "Create a virtual environment and run tests"

cmdw run setup

Reuse a Deployment Target

cmdw add-var deploy.target production

cmdw create deploy \
  "npm run build" \
  "npm run deploy -- --target {{global.deploy.target}}"

cmdw run deploy

Run the Same Command for Several Items

cmdw create check-domains "curl -I https://{{domain[]}}"
cmdw run check-domains --set "domain[]=example.com,example.org"

Notes

  • Commands are executed by your system shell.
  • Review workflows before running them, especially if they include destructive shell commands.
  • Secrets saved as global variables are stored as plain text in ~/.cmdw/globals.json.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

commands_workflows-0.2.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

commands_workflows-0.2-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file commands_workflows-0.2.tar.gz.

File metadata

  • Download URL: commands_workflows-0.2.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for commands_workflows-0.2.tar.gz
Algorithm Hash digest
SHA256 f968f5304f57589e23aa0b08a70fe705d405cb6cac443728b8aee026066410fc
MD5 c43f65c2c7f74ddbbb37b19c4ac1c883
BLAKE2b-256 13b72e845bdc51bd37e2e3c1bcd01a201300a980970f2b0fb1eb4be7b6dbb9cd

See more details on using hashes here.

File details

Details for the file commands_workflows-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for commands_workflows-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1906823a0907053d0b35e7accd25cc889c979482e8c0e885459b0a6458f6fc5b
MD5 e109c7ec2b687016ed7d527bc211ade8
BLAKE2b-256 85c227e1625a176e1550cbcc98ab390bad6c34abadefefe30f66afb518114e22

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page