Developer-first reference for the PromptG CLI (promptg).
npm install -g @promptg/cli# Create a project store (.promptg/)
promptg init
# Save a prompt (stdin -> stored JSON)
echo "Review this code for security and correctness." | promptg prompt save code-review
# Render to stdout (pipe anywhere)
promptg get code-review | llmVariables:
git diff > diff.txt
promptg get pr-review --var diff@diff.txt --var language=TypeScript | llmThese options are defined on the root CLI and work with all commands:
--format <format>:text|json(default:text)--json: shorthand for--format json-q, --quiet: suppress non-essential status output (stderr)--debug: include diagnostic details in JSON errors (and print stacks in text mode)
These options are common across many commands:
--store <store>:auto|project|global(default:auto)--var <key=value|key@filepath>: variable override (repeatable) (get/prompt render/prompt new --from-template)-i, --interactive: prompt for variables (TTY only) (get/prompt render/prompt new --from-template)--copy: copy rendered output to clipboard (where supported)
promptg p=promptg promptpromptg t=promptg templatepromptg get <name>=promptg prompt render <name>listhas aliasls(e.g.,promptg prompt ls)deletehas aliasrm(e.g.,promptg prompt rm)
Initialize a .promptg/ folder in your project.
promptg initCreates:
.promptg/prompts/- For saved prompts.promptg/templates/- For reusable templates.promptg/packs/- For prompt packs
Options:
-q, --quiet- Suppress status output (stderr)
Save a prompt from stdin.
echo "Review this code for security" | promptg prompt save security-review
# Or from a file
cat my-prompt.txt | promptg prompt save my-promptNotes:
- This command requires stdin (piped/redirected). It will error if you run it with no input.
Options:
--store <mode>- Specify store location-q, --quiet- Suppress status output (stderr)
Create a new prompt (from scratch or from a template).
promptg prompt new code-review
promptg prompt new my-pr-review --from-template pr-reviewNotes:
- Without
--from-template, uses your configured editor (commonly$VISUAL/$EDITOR) to capture multiline content. - With
--from-template, deep copies the embedded prompt in the template (wrapper metadata is ignored).
Options:
--force- Overwrite if already exists--from-template <template-name>- Create by instantiating a template--var <key=value|key@filepath>- Seeddefaultson the created prompt (repeatable; requires--from-template)--interactive- Prompt for missing defaults (TTY only; requires--from-template)--store <mode>- Specify store location-q, --quiet- Suppress status output (stderr)
Edit an existing prompt in your editor.
promptg prompt edit code-reviewNotes:
- Default mode edits prompt content only (multiline supported).
- Use
--rawto edit the full prompt JSON document (metadata, defaults, interactive). - Uses your configured editor (commonly
$VISUAL/$EDITOR).
Options:
--raw- Edit the full prompt JSON document--store <mode>- Specify store location-q, --quiet- Suppress status output (stderr)
Rename a prompt (atomic).
promptg prompt rename code-review security-reviewOptions:
--force- Overwrite if target exists--store <mode>- Specify store location-q, --quiet- Suppress status output (stderr)
Edit prompt metadata (display name, description, tags).
promptg prompt meta code-review --description "Review code for security" --tag security --tag reviewOptions:
--display-name <value>- Set display name--description <value>- Set description--tag <tag>- Add tag (repeatable)--remove-tag <tag>- Remove tag (repeatable)--store <mode>- Specify store location-q, --quiet- Suppress status output (stderr)
Delete a prompt.
promptg prompt delete code-review
promptg prompt rm code-reviewOptions:
--store <mode>- Specify store location-q, --quiet- Suppress status output (stderr)
Show a prompt as JSON (does not render).
promptg prompt show code-review
promptg prompt show code-review --format jsonOptions:
--store <mode>- Specify store location--format <format>/--json- Output format (text|json)
Render a prompt.
Alias: promptg get <name>.
Retrieve and render a prompt.
Alias: promptg prompt render <name>.
# Basic usage
promptg get code-review
# With variables
promptg get code-review --var language=TypeScript --var focus=security
# Load variable from file
promptg get code-review --var diff@changes.txt
# Interactive mode
promptg get code-review --interactive
# Copy to clipboard
promptg get code-review --copy
# JSON output
promptg get code-review --format jsonNotes:
--store autoprefers the nearest project store and falls back to global if the prompt is missing.- In text mode,
getmay warn if a project prompt overrides a global prompt with the same name.
Options:
--var <key=value>- Override variable (repeatable)--var <key@filepath>- Load variable from file--interactive- Prompt for variables interactively--info- Show metadata + rendered output--unfilled- Show template with placeholders--copy- Copy output to clipboard--quiet- Suppress status messages--store <mode>- Specify store location--format <format>/--json- Output format (text|json)
Show a template as JSON. Templates are not rendered/executed.
promptg template show pr-review
promptg template show pr-review --embedded
promptg template show pr-review --format jsonOptions:
--embedded- Show embedded prompt JSON only--store <mode>- Specify store location--format <format>/--json- Output format (text|json)
Create a template by editing JSON in your editor.
promptg template new pr-reviewNotes:
- Opens your editor to edit template JSON (useful for authoring metadata + interactive questions).
Options:
--force- Overwrite if already exists--store <mode>- Specify store location-q, --quiet- Suppress status output (stderr)
Edit an existing template JSON in your editor.
promptg template edit pr-reviewNotes:
- Opens your editor to edit the template JSON.
Options:
--store <mode>- Specify store location-q, --quiet- Suppress status output (stderr)
Delete a template.
promptg template delete pr-review
promptg template rm pr-reviewOptions:
--store <mode>- Specify store location-q, --quiet- Suppress status output (stderr)
List all saved prompts.
# Text output
promptg prompt list
# JSON output
promptg prompt list --format json
# Filter and detailed output (text mode)
promptg prompt list --filter security
promptg prompt list --longOptions:
--store <mode>- Specify store location--format <format>/--json- Output format (text|json)--filter <substring>- Filter prompts by name/description/tags-l, --long- Detailed output (text mode only)
List all templates.
# Text output
promptg template list
# JSON output
promptg template list --format json
# Filter and detailed output (text mode)
promptg template list --filter review
promptg template list --longOptions:
--store <mode>- Specify store location--format <format>/--json- Output format (text|json)--filter <substring>- Filter templates by name/description/tags-l, --long- Detailed output (text mode only)
Import a prompt or template from a file or URL.
# From local file
promptg import ./my-prompt.json
# From URL
promptg import https://example.com/prompt.json
# Force overwrite
promptg import ./my-prompt.json --forceNotes:
- If the source starts with
http://orhttps://, it is treated as a URL by default (use--fileto force file mode).
Options:
--force- Overwrite if already exists--file- Treat source as file path--url- Treat source as URL--store <mode>- Specify store location-q, --quiet- Suppress status output (stderr)
Build a prompt pack for distribution.
promptg pack build my-pack --pack-version 1.0.0Options:
--pack-version <semver>- Pack version (semver)--store <mode>- Specify store location (auto|project|global)--force- Overwrite if the pack already exists--quiet- Suppress status output
Writes to <store>/packs/promptg-pack-<name>.json.
Install a prompt pack.
# From local file
promptg pack install ./pack.json
# From URL
promptg pack install https://example.com/starter-pack.json
# Force overwrite
promptg pack install ./pack.json --force
# Install only new items
promptg pack install ./pack.json --only-new
# Quiet mode
promptg pack install ./pack.json --quietOptions:
--force- Overwrite existing prompts/templates--only-new- Skip items that already exist--quiet- Suppress status messages--store <mode>- Specify store location (auto|project|global)
Validate prompts, templates, and packs in the selected store.
# Text output
promptg validate
# JSON output
promptg validate --format jsonChecks:
- JSON syntax
- Schema compliance
- Variable references
Options:
--store <mode>- Specify store location (auto|project|global)--format <format>/--json- Output format (text|json)-q, --quiet- Suppress status output (stderr)
Show current store configuration.
# Text output
promptg status
# JSON output
promptg status --format jsonDisplays:
- CLI version
- Current working directory
- Global store location
- Project store location (if detected)
- Store conventions
Options:
--format <format>/--json- Output format (text|json)
Print the resolved store root directory.
promptg store path
promptg store path --store project
promptg store path --store globalOptions:
--store <mode>- Specify store location (auto|project|global)
Diagnose common environment and store issues.
promptg doctor
promptg doctor --store project
promptg doctor --format jsonOptions:
--store <mode>- Specify store location (auto|project|global)--format <format>/--json- Output format (text|json)
Print the CLI version.
promptg version
promptg version --format jsonOptions:
--format <format>/--json- Output format (text|json)
--var key=valueLoad variable value from a file (preserves newlines):
--var key@filepathExample:
git diff > changes.txt
promptg get code-review --var diff@changes.txt | llmConstraints:
- File must resolve within the current directory tree
- Maximum file size: 10MB
- Symlinks are resolved; the resolved target must still be within the current directory tree
Define interactive variables in your prompt/template JSON:
{
"kind": "template",
"schemaVersion": "1",
"name": "my-template",
"displayName": "Code Review Template",
"description": "Interactive template for reviewing code with customizable language and focus",
"prompt": {
"kind": "prompt",
"schemaVersion": "1",
"name": "my-template",
"content": "Review {{language}} code for {{focus}}",
"x-promptg-interactive": {
"language": {
"question": "What programming language?",
"help": "e.g., TypeScript, Python, Go"
},
"focus": {
"question": "What should we focus on?",
"required": true
}
}
}
}Then use --interactive:
promptg get my-prompt --interactiveAuto (default):
- Detects
.promptg/in current directory or parents - Falls back to global if not found
Project:
- Forces project store
- Errors if no
.promptg/found
Global:
- Forces global store (
~/.promptg/) - Ignores project stores
# Use project store (error if not found)
promptg get code-review --store project
# Use global store
promptg get code-review --store global
# Auto-detect (default)
promptg get code-reviewPromptG is designed for Unix pipes:
# Pipe prompt to LLM
promptg get code-review | llm
# Provide multiline inputs (diffs/logs) via --var key@file
git diff > diff.txt
promptg get security-scan --var diff@diff.txt | llm
# Save LLM output
promptg get docs | llm > output.mdSome commands support --format json (or --json) for programmatic use:
promptg prompt list --format json
promptg get code-review --format json
promptg template show pr-review --format json
promptg status --format json
promptg doctor --format json
promptg version --format json
promptg validate --format jsonOutput format:
{
"ok": true,
"data": { ... },
"warnings": []
}Error format:
{
"ok": false,
"error": {
"code": "USAGE",
"message": "..."
},
"warnings": []
}0- Success1- Validation or runtime error2- Usage error (invalid CLI syntax)130- Canceled (Ctrl+C during interactive prompts)
NO_COLOR- Disable the small amount of colored stderr output (status/hints/separators)
Save and use a prompt:
promptg init
echo "Review for security issues" | promptg prompt save security
git diff > diff.txt
promptg get security --var diff@diff.txt | llmUse variables:
promptg get code-review \
--var language=TypeScript \
--var focus=performanceLoad diff from file:
git diff origin/main...HEAD > pr-diff.txt
promptg get pr-review --var diff@pr-diff.txt | llmInteractive prompting:
promptg get code-review --interactive --copyInstall a pack:
promptg pack install https://example.com/promptg-pack-typescript.json
promptg template list- Text mode (default): stdout = primary output; stderr = status/warnings/errors.
- JSON mode (
--format json/--json): stdout = valid JSON only (exactly one JSON value); stderr = empty by default (diagnostics only with--debug).
Success:
{ "ok": true, "data": <any>, "warnings": [ { "code": "<string>", "message": "<string>" } ] }
Error:
{ "ok": false, "error": { "code": "USAGE|VALIDATION|RUNTIME", "message": "<string>", "details": { } }, "warnings": [ { "code": "<string>", "message": "<string>" } ] }
warningsis always present (possibly empty) and is advisory (it never flipsok).error.detailsis optional and must be JSON-serializable when present.- JSON mode prints exactly one JSON object followed by a trailing newline.
- In JSON mode,
--helpreturns:
{ "ok": true, "data": { "help": "<string>" }, "warnings": [] }
Top-level error.code:
USAGE- invalid CLI usage / argument parsing / unsupported flag combinations.VALIDATION- invalid user data (bad JSON, schema/shape violations, missing required fields, name rules).RUNTIME- unexpected failures, including IO and network failures.
Infra-level error codes (e.g. NOT_FOUND, CONFLICT, INVALID_DATA, NETWORK) may be included under
error.details for debugging/tooling, but do not change the meaning of the top-level error.code
unless the contract is versioned.
0success;1validation/runtime error;2usage error;130canceled (Ctrl+C in interactive).
- With
--debug, extra diagnostics may appear undererror.details.debug(e.g. stack, cause) without changing exit codes or top-level error semantics.