Tutorial covering the @devspeak/cli npm package: global installation, API key authentication via devspeak login, translating text from arguments or stdin, attaching local PDF and Markdown context with --file, and wiring the CLI into a CI pipeline using the DEVSPEAK_API_KEY environment variable.
Automate Specifications with the DevSpeak CLI
The DevSpeak CLI exposes the same translation engine as the web app, which makes it usable from a terminal, a shell script, or a CI job. This tutorial covers installation through a working CI step.
What You'll Learn
Prerequisites
Time Estimate
~8 minutes
Step 1 — Install
`` npm install -g @devspeak/clibash
`
Verify the install:
`bash
devspeak --version
`Step 2 — Authenticate
`bash
devspeak login
`
The key is written to $XDG_CONFIG_HOME/devspeak/config.json with mode 600. Confirm it registered:
`bash
devspeak whoami
`
The output masks the key. It never prints in full, which makes whoami safe to run in a shared terminal.Checkpoint
At this point you should have:
printing a version number reporting a masked key and an endpointIf whoami fails, run devspeak doctor for a full environment audit.Step 3 — Translate
Three input paths are available. All three hit POST /api/v1/translate.
` devspeak translate "Users should be able to export their data as CSV"bash
Positional argument
Piped from stdin
cat notes.txt | devspeak translate --format "Jira Tickets"
With local file context
devspeak translate "Implement the auth flow" --file ./docs/prd.pdf
`
--file accepts PDF, Markdown, and plain text. Each file can be up to 10 MiB, but one request carries at most about 3.1 MB of attachments in total — that total is the limit you will actually hit. From CLI version 1.5.2, the CLI checks locally, before any network call, that the file is non-empty, a supported type, and within that 3.1 MB total, so those failures are immediate. Older versions only checked for 10 MB, so a larger file got through and the API then rejected it. If devspeak --version reports a version below 1.5.2, upgrade with npm install -g @devspeak/cli.
Step 4 — Run It in CI
devspeak login is interactive and will hang in a CI runner. Use the environment variable instead — it takes precedence over any stored key.
`yaml
env:
DEVSPEAK_API_KEY: ${{ secrets.DEVSPEAK_API_KEY }}
run: |
devspeak translate "$(cat request.txt)" \
--audience "Senior Dev" \
--format "Technical Spec" > spec.md
`
Because documents go to stdout and diagnostics go to stderr, the redirect above captures only the specification.Troubleshooting
command not found: devspeak
The global npm bin directory is not on your PATH. Run npm prefix -g, add its bin subdirectory to your PATH, or invoke the CLI with npx @devspeak/cli. command -v devspeak shows which binary your shell resolves.
401 Unauthorized in CI but not locally
The runner is reading a different key. DEVSPEAK_API_KEY overrides the config file, so check the secret is exposed to the step and not just the workflow.
Invalid value for --audience
Audience, context, format, and tone are validated locally against the same enums the API enforces. Run devspeak translate --help for the accepted values.Summary
You've learned how to: