@prompt-template/cli
v0.3.0
Published
A CLI to inspect and format prompt templates
Readme
@prompt-template/cli
A CLI to inspect and format prompt templates. Provide input variables via CLI flags and pipe formatted prompt templates into code agents, such as Claude Code or Codex.
Installation
Install the following dependencies in the project containing your prompt templates:
npm i @prompt-template/core @prompt-template/cliUsage
# Create a new prompt template
npx @prompt-template/cli create
# Inspect a prompt template
npx @prompt-template/cli inspect <prompt-template-file>
# Format a prompt template
npx @prompt-template/cli format <prompt-template-file> --input <input>
# Pipe a formatted prompt template to a code agent
npx @prompt-template/cli format <prompt-template-file> | claudeNeed help? Run:
npx @prompt-template/cli helpExample workflow
Given the following ~/prompts/summarize-file.ts prompt template:
import { PromptTemplate } from '@prompt-template/core'
export default PromptTemplate.create`
Summarize the contents of ${'filePath'} in bullet points.
Additional instructions:
${{
name: 'instructions',
description: 'Additional instructions for summarization',
default: 'N/A',
}}
`Assumes
@prompt-template/coreis installed in~/prompts.
- Inspect the prompt template's input variables:
npx @prompt-template/cli inspect ~/prompts/summarize-file.ts> Input variables:
--filePath <filePath>
--instructions <instructions> (optional) Additional instructions for summarization
Example usage:
npx @prompt-template/cli format summarize-file.ts \
--filePath <filePath> \
--instructions <instructions>- Format the prompt template with input values (via CLI flags):
npx @prompt-template/cli format ~/prompts/summarize-file.ts \
--filePath /path/to/file.md> Summarize the contents of /path/to/file.md in bullet points.
Additional instructions:
N/A- Pipe the formatted prompt template to a code agent (e.g. Claude Code or Codex):
npx @prompt-template/cli format ~/prompts/summarize-file.ts \
--filePath /path/to/file.md | claude> Summary of /path/to/file.md...- Pipe the formatted prompt template to multiple code agents:
Serial:
for file in dir/*.md; do
npx @prompt-template/cli format ~/prompts/summarize-file.ts \
--instructions "Write the summary to an adjacent file suffixed with -summary.md" \
--filePath "$PWD/$file" | claude -p
doneParallel:
echo dir/*.md | xargs -n 1 -P 4 -I {} \
npx @prompt-template/cli format ~/prompts/summarize-file.ts \
--instructions "Write the summary to an adjacent file suffixed with -summary.md" \
--filePath "$PWD/{}" | claude -pSee the core package for more details and API documentation.
