StructKit supports environment variables to configure CLI arguments without requiring them to be specified on the command line. This is particularly useful for CI/CD pipelines, containerized environments, and automation workflows.
Environment variables allow you to set default values for CLI arguments. Command-line arguments always take precedence over environment variables, ensuring flexibility when needed.
Sets the global system prompt for OpenAI integration.
CLI Equivalent: --global-system-prompt / -p
Use Case: Typically a long or sensitive value that users want to set once. Avoids repeating the same prompt across multiple invocations. Ideal for CI/CD workflows and container initialization.
Example:
export STRUCTKIT_GLOBAL_SYSTEM_PROMPT="You are a helpful assistant for generating project structures."
structkit generate my-structure ./outputSets the path to the input store for template variables.
CLI Equivalent: --input-store / -n
Default: /tmp/structkit/input.json
Use Case: Allows users to set a consistent default location for input data. Useful for workflows that need persistent input across multiple runs.
Example:
export STRUCTKIT_INPUT_STORE="/home/user/structkit-inputs/data.json"
structkit generate my-structure ./outputSets the default backup location for file backups.
CLI Equivalent: --backup / -b
Use Case: Set a default backup location project-wide or environment-wide. Saves typing in repetitive operations. Useful for ensuring backups go to a specific location (e.g., mounted volume in containers).
Example:
export STRUCTKIT_BACKUP_PATH="/backups/structkit"
structkit generate my-structure ./outputSets the default strategy for handling existing files.
CLI Equivalent: --file-strategy / -f
Valid Values: overwrite, skip, append, rename, backup
Default: overwrite
Use Case: Let users set a preferred default strategy. Could prevent accidental data loss if set to 'skip' or 'backup' by default.
Example:
export STRUCTKIT_FILE_STRATEGY="backup"
structkit generate my-structure ./outputEnables or disables interactive mode for all commands.
CLI Equivalent: --non-interactive
Valid Values: true, 1, yes (case-insensitive) for enabled; any other value for disabled
Default: false
Use Case: Boolean flag useful for CI/CD pipelines. Could be set in environment and applied across all commands.
Example:
export STRUCTKIT_NON_INTERACTIVE=true
structkit generate my-structure ./outputSets the default output mode for the generate command.
CLI Equivalent: --output / -o
Valid Values: console, file
Default: file
Use Case: Some users might prefer 'console' output by default. Useful for pipeline integration.
Example:
export STRUCTKIT_OUTPUT_MODE="console"
structkit generate my-structure ./outputSets the path to custom structure definitions.
CLI Equivalent: --structures-path / -s
Use Case: Allows specifying custom structures directory that applies across all commands (generate, list, info, generate-schema).
Example:
export STRUCTKIT_STRUCTURES_PATH="/home/user/my-structures"
structkit list
structkit generate my-custom-structure ./outputSets the logging level for all commands.
CLI Equivalent: --log (generate command)
Valid Values: DEBUG, INFO, WARNING, ERROR, CRITICAL
Default: INFO
Use Case: Control verbosity of output for debugging or production deployments.
Example:
export STRUCTKIT_LOG_LEVEL="DEBUG"
structkit generate my-structure ./outputCommand-line arguments always take precedence over environment variables. This allows environment variables to set sensible defaults while maintaining the ability to override them when needed.
Precedence Order (highest to lowest):
- Command-line arguments
- Environment variables
- Built-in defaults
Example:
# Set default via environment variable
export STRUCTKIT_FILE_STRATEGY="backup"
# Override with CLI argument
structkit generate --file-strategy skip my-structure ./output
# Uses 'skip', not 'backup'
# Use default from environment
structkit generate my-structure ./output
# Uses 'backup' from STRUCTKIT_FILE_STRATEGYEnvironment variables are particularly useful when running StructKit in containers:
Docker Example:
docker run \
-e STRUCTKIT_STRUCTURES_PATH=/custom/structures \
-e STRUCTKIT_NON_INTERACTIVE=true \
-e STRUCTKIT_FILE_STRATEGY=backup \
-v /custom/structures:/custom/structures \
-v $(pwd):/workdir \
ghcr.io/httpdss/structkit:main generate my-structure /workdir/outputDocker Compose Example:
version: '3'
services:
structkit:
image: ghcr.io/httpdss/structkit:main
environment:
STRUCTKIT_STRUCTURES_PATH: /custom/structures
STRUCTKIT_NON_INTERACTIVE: "true"
STRUCTKIT_FILE_STRATEGY: backup
STRUCTKIT_LOG_LEVEL: DEBUG
volumes:
- /custom/structures:/custom/structures
- ./output:/workdir
command: generate my-structure /workdir/outputGitHub Actions Example:
name: Generate Project Structure
on: [push, pull_request]
jobs:
generate:
runs-on: ubuntu-latest
env:
STRUCTKIT_NON_INTERACTIVE: "true"
STRUCTKIT_BACKUP_PATH: /tmp/backups
STRUCTKIT_FILE_STRATEGY: backup
steps:
- uses: actions/checkout@v3
- name: Install StructKit
run: pip install structkit
- name: Generate structure
run: structkit generate my-structure ./generated-project
- name: Upload generated files
uses: actions/upload-artifact@v3
with:
name: generated-project
path: generated-project/GitLab CI Example:
generate_structure:
image: python:3.11
script:
- pip install structkit
- structkit generate my-structure ./output
artifacts:
paths:
- output/
only:
- main
environment:
- STRUCTKIT_NON_INTERACTIVE: "true"
- STRUCTKIT_FILE_STRATEGY: "backup"- Use Environment Variables for Defaults - Set environment variables for values that don't change frequently
- Override When Needed - Use CLI arguments for one-off changes or specific use cases
- Document Configuration - Document which environment variables are used in your project
- Sensitive Data - Store sensitive data (like API keys) in environment variables, not in configuration files
- Validation - Test environment variable configuration to ensure it works as expected
- Verify the environment variable is set:
echo $VARIABLE_NAME - Ensure you're using the correct variable name (case-sensitive on Linux/macOS)
- If running in Docker, check that the environment variable is passed correctly with
-e - Restart your terminal or shell session after setting the variable
This should not happen - CLI arguments always take precedence. If you're experiencing this:
- Verify the CLI argument is correctly formatted
- Check that you're using the correct argument name (e.g.,
--file-strategynot--strategy) - Ensure there are no spaces or special characters in the argument value
For STRUCTKIT_NON_INTERACTIVE, only true, 1, and yes (case-insensitive) are recognized as true values. All other values are treated as false, including:
"true "(with trailing space)"True"in mixed case"on"or"enable"
Use one of the recognized values for reliable behavior.