Get started with Struckdown in minutes.
# Install UV if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install struckdown
uv tool install git+https://github.com/benwhalley/struckdown
Set your LLM credentials:
export LLM_API_KEY="sk-..." # Your API key
export LLM_API_BASE="https://api.openai.com/v1"
export DEFAULT_LLM="gpt-4o-mini"
Test the CLI:
sd chat "Tell me a joke: [[joke]]"
This simple prompt asks the LLM to tell a joke and stores it in a variable called joke.
Struckdown uses [[slot]] syntax to tell the LLM where to generate responses:
sd chat "Explain quantum physics: [[explanation]]"
The final slot can be omitted in simple prompts:
sd chat "Tell me a joke" # Automatically becomes [[response]]
Specify the type of response you want:
# Boolean (true/false)
sd chat "Is the sky blue? [[bool:answer]]"
# Pick from options
sd chat "Choose a color [[pick:color|red,green,blue]]"
# Number extraction
sd chat "Price: $19.99 [[number:price]]"
# Integer
sd chat "Count the words: 'hello world' [[int:count]]"
Use `` to reference previous results:
sd chat "Name a fruit: [[fruit]]
<checkpoint>
Tell me a joke about : [[joke]]"
Process multiple files at once:
# Process text files
sd batch *.txt "Summarize in 5 words: [[summary]]" -o results.json
# Extract structured data
sd batch reviews/*.txt "Sentiment [[pick:sentiment|positive,negative,neutral]]" -o sentiment.csv
# Chain multiple operations
sd batch *.txt "Extract name: [[name]]" | \
sd batch "Generate email for : [[email]]" -k
Use <checkpoint> to create memory boundaries and save tokens:
sd chat "Long context...
Generate summary: [[summary]]
<checkpoint>
Translate to Spanish: [[translation]]"
Everything before <checkpoint> is forgotten – only the extracted variables (``) are available in the next section.
sd batch documents/*.txt "
Name: [[name]]
Email: [[email]]
Phone: [[number:phone]]
" -o contacts.csv
sd chat "Analyze this code:
\`\`\`python
def hello(): print('hi')
\`\`\`
Issues: [[issues]]
<checkpoint>
Issues found:
Suggested fixes: [[fixes]]"
sd batch emails/*.txt "
Sentiment: [[pick:sentiment|positive,negative,neutral]]
Urgent: [[bool:urgent]]
Category: [[pick:category|sales,support,billing,other]]
" -o classified.json