Scripting & AI Integration
This page covers how to use DevSpaces in non-interactive contexts such as scripts, CI/CD pipelines, or AI-powered development tools.
The Problemβ
When running DVS commands in a non-interactive context (scripts, cron jobs, AI assistants like Cursor or Claude Code), you may encounter this error:
the input device is not a TTY
This happens because DVS commands try to allocate a pseudo-TTY for interactive features, but no TTY is available in these contexts.
Solution: DVS_NO_TTYβ
Set the DVS_NO_TTY environment variable to disable TTY allocation:
DVS_NO_TTY=1 dvs php bin/console cache:clear
What it doesβ
When DVS_NO_TTY is set (any non-empty value):
- Disables the
-itflags on Docker exec commands (no TTY allocation) - Sets
INTERACTIVE=0(disables interactive prompts) - Disables footer display
Detection priorityβ
DVS automatically detects the execution context:
| Context | TTY available | DVS_NO_TTY | Result |
|---|---|---|---|
| Interactive terminal | Yes | Not set | Full interactive mode |
| Script/pipe | No | Not set | Auto non-interactive |
| Any context | Any | Set | Forced non-interactive |
Setting Up Aliasesβ
For convenience, create aliases in your shell configuration (~/.bashrc, ~/.zshrc):
# Standard DVS (interactive)
alias dvs='dvs'
# DVS for scripts and AI tools (non-interactive)
alias dvs-script='DVS_NO_TTY=1 dvs'
alias dvs-ai='DVS_NO_TTY=1 dvs'
Then reload your shell:
source ~/.zshrc # or ~/.bashrc
Usage examplesβ
# Interactive usage (default)
dvs shell
dvs php bin/console
# Script/AI usage (non-interactive)
dvs-script php bin/console cache:clear
dvs-ai composer install
AI Development Toolsβ
Cursor / Claude Codeβ
When using AI assistants with limited terminal capabilities:
# In your AI tool's terminal
DVS_NO_TTY=1 dvs php bin/console cache:clear
DVS_NO_TTY=1 dvs exec npm run build
CI/CD Pipelinesβ
For automated pipelines, use DVS_NO_TTY:
# GitHub Actions example
- name: Clear cache
run: DVS_NO_TTY=1 dvs php bin/console cache:clear
# GitLab CI example
deploy:
script:
- DVS_NO_TTY=1 dvs composer install --no-dev
Best Practicesβ
- Use
--forceor--yesfor DVS commands that require confirmation - Check exit codes in scripts to detect failures
- Use
--jsonoutput when parsing DVS output programmatically
# Get app info as JSON
DVS_NO_TTY=1 dvs info --json | jq '.name'
External tool flagsβ
Some tools executed via DVS have their own non-interactive flags. These are not DVS flags but flags passed to the underlying tool:
# Composer's --no-interaction flag
DVS_NO_TTY=1 dvs composer install --no-interaction
# Symfony Console's --no-interaction flag
DVS_NO_TTY=1 dvs php bin/console doctrine:migrations:migrate --no-interaction
# Artisan's --force flag
DVS_NO_TTY=1 dvs php artisan migrate --force
Troubleshootingβ
Command hangs?β
The command might be waiting for input from the underlying tool. Add the appropriate non-interactive flag for that tool:
# Composer
DVS_NO_TTY=1 dvs composer install --no-interaction
# Symfony/PrestaShop console
DVS_NO_TTY=1 dvs console cache:clear --no-interaction
# WP-CLI (usually non-interactive by default)
DVS_NO_TTY=1 dvs wp plugin list
Need colors in output?β
When DVS_NO_TTY is set, color output is disabled. If you need colors in a script context where a real TTY is available, don't set DVS_NO_TTY and let DVS auto-detect.