Use when user mentions phab, phabalicious, deployment tasks, copying data between environments, or needs help with dev/staging/production workflows - provides command suggestions, multi-step...
Help users safely work with Phabalicious (phab) CLI tool for deployment and DevOps tasks. Core principle: Understand user intent, suggest safe workflows, confirm destructive operations, and provide environment-aware guidance.
IMPORTANT: Focus on answering the user's question based on this skill's knowledge. Don't get sidetracked by:
Answer based on phabalicious knowledge even if the current directory lacks a fabfile. The user is asking for help, not environment detection.
Use this skill when user:
Symptoms and triggers:
These commands are safe to recommend without confirmation:
list, list:hosts, list:blueprints, list:backupsabout, version, get:property, find:property, outputshell (but warn if production: "Be careful - full access to production")db:shell, db:query for SELECT queries (warn about write operations)get:file, get:files-dump, get:sql-dump, get:backupNote: For command help, use: phab <command> --help
These commands modify data or state - REQUIRE explicit user confirmation:
copy-from - Overwrites destination database/files, auto-runs resetrestore - Overwrites current state with backupreset - Resets application to known state (reverts config, clears cache, resets admin password on dev)backup - Creates backup snapshotsdeploy - Deploys code (auto-backs up on non-dev, auto-resets after)install, install:from - New installationsapp:destroy - Destroys app (NO BACKUP!)db:drop, restore:sql-from-file - Database operationsdrush - Can run destructive Drupal commands (enable/disable modules, config changes, etc.)CRITICAL: ALWAYS follow these steps before suggesting destructive operations. Do NOT skip steps or add concerns beyond this protocol.
Required workflow for copy-from, reset, restore, app:destroy:
ALWAYS check uncommitted work FIRST (for reset, copy-from):
ALWAYS explain what will happen:
ALWAYS suggest backup first (unless operation auto-backs up like deploy):
phab backup"ALWAYS get explicit confirmation:
phab copy-from production?"ONLY THEN provide the command
For reset operations - MUST ask diagnostic questions:
When suggesting ANY operation on production:
ddev (local development environment)--config execute on ddev by defaultddev (Local Development):
deploy on ddev: Valid but unusual (runs reset/composer)copy-from, reset, backupRemote Environments (staging, production, live, etc.):
--config=<environment> flagdeploy is the primary operationphab --config=staging deployUser says: "I need to deploy my changes"
User says: "I need production data"
phab copy-from production to local ddev--skip-reset)copy-from <source> [what] where [what] = db, files, or omitted (both)--skip-reset - Skip automatic reset after copy-from--skip-drop-db - Don't drop database before import (use cautiously)backup [what] where [what] = db, files, or omitted (both)db:query "SQL QUERY" - Executes SQL directly (not in official docs but available)phab --config=staging db:query "SELECT * FROM users LIMIT 10"List commands and hosts:
phab list # Show all available commands
phab list:hosts # List configured hosts
phab list:hosts -v # Verbose (shows descriptions & URLs)
phab list:blueprints # Show blueprint configurations
phab list:backups # Display available backups
Get help:
phab <command> --help # Get help for specific command
# Example: phab deploy --help
Get configuration info:
phab about # Show ddev configuration
phab --config=staging about # Show staging configuration
phab --config=staging about -v # Include inheritance sources
phab version # Show installed code version
phab get:property docker.service # Get specific property
phab find:property # Interactive property search
phab output # Print computed config as YAML
Shell access:
phab shell # Open shell on ddev (local)
phab --config=staging shell # Open shell on staging
phab --config=production shell # ā ļø Production shell (warn user!)
Deploy code:
phab --config=staging deploy # Deploy latest to staging
phab --config=staging deploy branch # Deploy specific branch
phab --config=production deploy # ā ļø Deploy to production
Note: deploy auto-backs up (non-dev) and auto-resets after
Reset installation:
phab reset # Reset ddev to known state
phab --config=staging reset
Note: Reverts config, clears cache, runs updates, resets admin password (dev) - CONFIRM first!
Backup:
phab backup # Backup ddev (db + files)
phab backup db # Backup database only
phab backup files # Backup files only
phab --config=staging backup
Copy data between environments:
phab copy-from production # Copy db + files from production
phab copy-from production db # Copy database only
phab copy-from staging files # Copy files only
phab copy-from production --skip-reset # Skip auto-reset
phab copy-from staging --skip-drop-db # Don't drop db (risky!)
Note: Auto-runs reset after copying (unless --skip-reset)
Restore backup:
phab restore <commit-hash> # Restore from backup
phab list:backups # First, see available backups
Execute SQL queries directly (RECOMMENDED):
# Use db:query for quick database queries (fastest method)
phab db:query "SELECT * FROM users LIMIT 10"
phab --config=staging db:query "SELECT id, name FROM users WHERE status=1"
phab --config=staging db:query "DESCRIBE users"
Note: Safe for SELECT queries, warn about INSERT/UPDATE/DELETE
Interactive database access:
phab db:shell # Open database client on ddev
phab --config=staging db:shell # Open database client on staging
For Drupal sites:
phab drush "sql-query 'SELECT * FROM users LIMIT 10'" # Run SQL query
phab --config=staging drush "sql-query 'SELECT ...'"
Note: drush can run destructive commands - confirm before suggesting config changes, module operations, etc.
Download files:
phab get:file /path/to/remote/file # Download specific file
phab get:files-dump # Download tar of files folder
phab get:sql-dump # Download database dump
phab --config=production get:backup <hash> # Download backup locally
Upload files:
phab put:file /path/to/local/file
phab put:file /path/to/local/file --destination=/remote/path
Scenario: User needs fresh production data for debugging
Safe approach:
Check for uncommitted work:
git status
Backup current local state:
phab backup
Explain what will happen: "This will overwrite your local database with production data"
Get confirmation, then execute:
phab copy-from production
Note: Auto-runs reset after copying
Alternative - database only:
phab backup db
phab copy-from production db
Scenario: User wants to deploy changes
First, clarify environment:
Safe deployment to staging:
# 1. Ensure code is committed
git status
git push
# 2. Deploy to staging (auto-backs up, auto-resets)
phab --config=staging deploy
# 3. Test in staging
# 4. Only then deploy to production if all looks good
Deployment to production (extra careful):
# ā ļø Extra confirmation needed
phab --config=production deploy
Note: Auto-backs up database before deploying
Scenario: User's environment is "broken" and they want to reset
Don't jump straight to reset - diagnose first:
Ask what's actually broken: "What error are you seeing? What's not working?"
Try less destructive fixes first:
# Maybe just need to update code?
phab deploy
# Or clear cache (Drupal)?
phab drush "cc all -y"
# Or run composer?
phab shell
# then: composer install
Only if those don't work, suggest reset:
phab backup
phab reset
If still broken, suggest fresh install from production:
phab copy-from production
Scenario: User wants to check data in remote database
Quick query (read-only):
# Direct query (fastest)
phab --config=staging db:query "SELECT * FROM users LIMIT 10"
# Or open interactive shell
phab --config=staging db:shell
# Then run SQL commands interactively
For Drupal:
phab --config=staging drush "sql-query 'SELECT * FROM users LIMIT 10'"
Best practices:
DESCRIBE table_name to see structureScenario: User needs command-line access to environment
For non-production:
phab --config=staging shell
For production (extra warning):
phab --config=production shell
ā ļø Warn: "Be careful - you'll have full access to production. Suggest read-only operations when possible."
Common shell use cases:
tail -f /var/log/...df -hps aux | grep phpScenario: User wants to compare configurations
Get configuration output:
phab --config=staging output > staging-config.yaml
phab --config=production output > production-config.yaml
diff staging-config.yaml production-config.yaml
Check specific properties:
phab --config=staging get:property database.name
phab --config=production get:property database.name
Forgetting --config flag for remote environments
Not checking uncommitted work before reset/copy-from
git status firstNot backing up before destructive operations
phab backupAssuming "deploy" means remote when user might mean ddev
Running destructive commands on production without double-checking