$npx -y skills add Impertio-Studio/Frappe_Claude_Skill_Package --skill frappe-ops-benchUse when running bench commands, managing sites, configuring multi-tenancy, or setting up domains. Prevents misconfigured bench environments, broken site routing, and DNS mismatches. Covers bench CLI commands, site creation, bench init, multi-tenancy setup, DNS-based routing, com
| 1 | # Bench CLI Complete Reference |
| 2 | |
| 3 | Complete bench CLI reference for site management, app lifecycle, configuration, and multi-tenancy. |
| 4 | |
| 5 | **Version**: v14/v15/v16 |
| 6 | |
| 7 | --- |
| 8 | |
| 9 | ## Quick Reference: Essential Commands |
| 10 | |
| 11 | | Task | Command | |
| 12 | |------|---------| |
| 13 | | Create bench | `bench init myproject --frappe-branch version-15` | |
| 14 | | Create site | `bench new-site mysite.localhost --admin-password admin` | |
| 15 | | Set default site | `bench use mysite.localhost` | |
| 16 | | Get app | `bench get-app erpnext --branch version-15` | |
| 17 | | Install app | `bench --site mysite install-app erpnext` | |
| 18 | | Start dev server | `bench start` | |
| 19 | | Run migrations | `bench --site mysite migrate` | |
| 20 | | Build assets | `bench build --app myapp` | |
| 21 | | Backup site | `bench --site mysite backup` | |
| 22 | | Restore backup | `bench --site mysite restore /path/to/backup.sql.gz` | |
| 23 | | Open console | `bench --site mysite console` | |
| 24 | | Open DB shell | `bench --site mysite mariadb` | |
| 25 | | Check scheduler | `bench doctor` | |
| 26 | | View pending jobs | `bench show-pending-jobs` | |
| 27 | | Update everything | `bench update` | |
| 28 | | Drop site | `bench drop-site mysite --force` | |
| 29 | |
| 30 | --- |
| 31 | |
| 32 | ## Workflow 1: Creating a New Bench |
| 33 | |
| 34 | ```bash |
| 35 | # Initialize bench with specific Frappe version |
| 36 | bench init myproject --frappe-branch version-15 |
| 37 | |
| 38 | # With Python version |
| 39 | bench init myproject --frappe-branch version-15 --python python3.11 |
| 40 | |
| 41 | # Enter bench directory (REQUIRED for all subsequent commands) |
| 42 | cd myproject |
| 43 | ``` |
| 44 | |
| 45 | **What `bench init` creates:** |
| 46 | |
| 47 | ``` |
| 48 | myproject/ |
| 49 | ├── apps/ # Installed Frappe apps (frappe is default) |
| 50 | ├── sites/ # All sites and shared config |
| 51 | │ └── common_site_config.json |
| 52 | ├── config/ # Redis, Procfile, supervisor configs |
| 53 | ├── env/ # Python virtual environment |
| 54 | ├── logs/ # Log files |
| 55 | └── Procfile # Process definitions for bench start |
| 56 | ``` |
| 57 | |
| 58 | ### Critical Rules |
| 59 | |
| 60 | - **ALWAYS** specify `--frappe-branch` to pin Frappe version |
| 61 | - **ALWAYS** run commands from inside the bench directory |
| 62 | - **NEVER** run bench commands as root — use a dedicated frappe user |
| 63 | |
| 64 | --- |
| 65 | |
| 66 | ## Workflow 2: Site Management |
| 67 | |
| 68 | ### Creating Sites |
| 69 | |
| 70 | ```bash |
| 71 | # Basic site creation |
| 72 | bench new-site mysite.localhost --admin-password admin |
| 73 | |
| 74 | # With specific database |
| 75 | bench new-site mysite.localhost --db-name mysite_db --admin-password admin |
| 76 | |
| 77 | # With MariaDB root password |
| 78 | bench new-site mysite.localhost --mariadb-root-password rootpass --admin-password admin |
| 79 | |
| 80 | # Install apps during creation |
| 81 | bench new-site mysite.localhost --admin-password admin --install-app erpnext |
| 82 | ``` |
| 83 | |
| 84 | ### Setting Default Site |
| 85 | |
| 86 | ```bash |
| 87 | bench use mysite.localhost |
| 88 | # OR set environment variable for current session: |
| 89 | export FRAPPE_SITE=mysite.localhost |
| 90 | ``` |
| 91 | |
| 92 | ### Dropping a Site |
| 93 | |
| 94 | ```bash |
| 95 | bench drop-site mysite.localhost --force |
| 96 | # Deletes database and archives site directory |
| 97 | ``` |
| 98 | |
| 99 | ### Site Directory Structure |
| 100 | |
| 101 | ``` |
| 102 | sites/mysite.localhost/ |
| 103 | ├── site_config.json # Site-specific config (db credentials) |
| 104 | ├── private/ # Auth-required files, backups |
| 105 | ├── public/ # Publicly accessible files |
| 106 | ├── locks/ # Scheduler lock files |
| 107 | └── task-logs/ # Scheduler task logs |
| 108 | ``` |
| 109 | |
| 110 | --- |
| 111 | |
| 112 | ## Workflow 3: App Management |
| 113 | |
| 114 | ```bash |
| 115 | # Download app from GitHub |
| 116 | bench get-app erpnext --branch version-15 |
| 117 | bench get-app https://github.com/org/custom-app.git --branch main |
| 118 | |
| 119 | # Install app on a site |
| 120 | bench --site mysite install-app erpnext |
| 121 | |
| 122 | # List installed apps |
| 123 | bench --site mysite list-apps |
| 124 | |
| 125 | # Remove app from site (creates backup first) |
| 126 | bench --site mysite uninstall-app custom_app |
| 127 | |
| 128 | # Remove app from bench entirely |
| 129 | bench remove-app custom_app |
| 130 | |
| 131 | # Switch app branch |
| 132 | bench switch-to-branch version-15 erpnext frappe |
| 133 | |
| 134 | # Exclude app from updates |
| 135 | bench exclude-app custom_app |
| 136 | |
| 137 | # Re-include app in updates |
| 138 | bench include-app custom_app |
| 139 | ``` |
| 140 | |
| 141 | ### Critical Rules |
| 142 | |
| 143 | - **ALWAYS** `get-app` before `install-app` — get downloads, install activates |
| 144 | - **ALWAYS** backup before `uninstall-app` — it deletes app-related data |
| 145 | - **NEVER** manually delete app folders — use `bench remove-app` |
| 146 | |
| 147 | --- |
| 148 | |
| 149 | ## Workflow 4: bench update: What It Does |
| 150 | |
| 151 | ```bash |
| 152 | # Full update (pull + migrate + build + restart) |
| 153 | bench update |
| 154 | |
| 155 | # Update specific app only |
| 156 | bench update --pull --app erpnext |
| 157 | |
| 158 | # Skip build step |
| 159 | bench update --no-build |
| 160 | |
| 161 | # Skip backup |
| 162 | bench update --no-backup |
| 163 | |
| 164 | # Reset to upstream (DESTROYS local changes) |
| 165 | bench update --reset |
| 166 | ``` |
| 167 | |
| 168 | **`bench u |