From frappe-fullstack
Executes Frappe Bench CLI commands like migrate, build, clear-cache, backup, restore with site awareness, safety checks, and validation.
npx claudepluginhub unityappsuite/frappe-claude --plugin frappe-fullstack<command> [--site <sitename>]# Execute Bench Command Safely execute Frappe Bench CLI commands with proper site context and validation. ## Arguments Parse the user's input: $ARGUMENTS Common commands: - `migrate` - Run database migrations - `build` - Build JavaScript/CSS assets - `clear-cache` - Clear Redis cache - `console` - Open Python console - `start` - Start development server - `update` - Update apps and migrate - `backup` - Backup site - `restore` - Restore from backup ## Process ### Step 1: Detect Bench Directory Find the frappe-bench directory: ### Step 2: Identify Available Sites ### Step 3: Deter...
Safely execute Frappe Bench CLI commands with proper site context and validation.
Parse the user's input: $ARGUMENTS
Common commands:
migrate - Run database migrationsbuild - Build JavaScript/CSS assetsclear-cache - Clear Redis cacheconsole - Open Python consolestart - Start development serverupdate - Update apps and migratebackup - Backup siterestore - Restore from backupFind the frappe-bench directory:
# Check if we're in a bench directory
if [ -f "sites/apps.txt" ]; then
echo "Bench directory found: $(pwd)"
else
# Try to find bench directory
find ~ -name "frappe-bench" -type d 2>/dev/null | head -3
fi
# List available sites
ls sites/ | grep -v "apps.txt\|common_site_config.json\|assets"
# Check default site
cat sites/currentsite.txt 2>/dev/null || echo "No default site set"
Based on the requested operation:
bench --site <sitename> migrate
Safety checks:
# Build all apps
bench build
# Build specific app
bench build --app <app_name>
# Build with verbose output
bench build --verbose
# Production build
bench build --production
bench --site <sitename> clear-cache
bench --site <sitename> console
# Example usage in console:
# >>> doc = frappe.get_doc("Customer", "CUST-001")
# >>> frappe.db.sql("SELECT * FROM tabCustomer LIMIT 5", as_dict=True)
bench start
Note: This will occupy the terminal. Use Ctrl+C to stop.
# Full update
bench update
# Update without backup
bench update --no-backup
# Update specific apps
bench update --apps frappe,erpnext
# Update without migrations
bench update --no-migrations
Safety checks:
# Basic backup
bench --site <sitename> backup
# With files
bench --site <sitename> backup --with-files
Output location: sites/<sitename>/private/backups/
bench --site <sitename> restore <path_to_backup.sql.gz>
# With files
bench --site <sitename> restore <backup.sql.gz> \
--with-private-files <private.tar> \
--with-public-files <public.tar>
Safety checks:
# Set admin password
bench --site <sitename> set-admin-password <newpassword>
# Add system manager
bench --site <sitename> add-system-manager <email>
# Enable/disable scheduler
bench --site <sitename> enable-scheduler
bench --site <sitename> disable-scheduler
# Show pending jobs
bench --site <sitename> show-pending-jobs
# Doctor - check site health
bench --site <sitename> doctor
# MariaDB console
bench --site <sitename> mariadb
# Export fixtures
bench --site <sitename> export-fixtures
# Run tests
bench --site <sitename> run-tests --app <app_name>
drop-site - Deletes entire sitereinstall - Drops and recreates databaserestore - Overwrites current datareset - Resets to fresh installBefore running on production:
For any command, check:
Common issues:
# Check available sites
ls sites/
# Rebuild environment
bench setup env
pip install -e apps/frappe -e apps/erpnext
# Check error logs
tail -100 logs/frappe.log
# Skip failing patches
bench --site <sitename> migrate --skip-failing
# Clear node modules and rebuild
rm -rf node_modules
yarn install
bench build
After command execution:
| Task | Command |
|---|---|
| Start dev server | bench start |
| Migrate database | bench --site <site> migrate |
| Clear cache | bench --site <site> clear-cache |
| Build assets | bench build |
| Backup site | bench --site <site> backup |
| View logs | tail -f logs/frappe.log |
| Python console | bench --site <site> console |
| MySQL console | bench --site <site> mariadb |
| Run tests | bench --site <site> run-tests |
| Check health | bench --site <site> doctor |