$npx -y skills add Impertio-Studio/Frappe_Claude_Skill_Package --skill frappe-ops-app-lifecycleUse when scaffolding a new Frappe app, configuring app settings, building assets, running tests, deploying, updating, or publishing to marketplace. Prevents broken app structure from incorrect scaffolding, missing setup.py fields, and failed builds. Covers bench new-app, app dire
| 1 | # App Lifecycle Management |
| 2 | |
| 3 | ## Quick Reference |
| 4 | |
| 5 | | Command | Purpose | When to Use | |
| 6 | |---|---|---| |
| 7 | | `bench new-app` | Scaffold new app | Starting a new project | |
| 8 | | `bench get-app URL` | Clone from Git | Installing existing app | |
| 9 | | `bench --site SITE install-app` | Install on site | After get-app or new-app | |
| 10 | | `bench --site SITE remove-app` | Uninstall from site | Removing app from site | |
| 11 | | `bench remove-app` | Remove from bench | Removing app entirely | |
| 12 | | `bench --site SITE migrate` | Run patches + sync | After code changes | |
| 13 | | `bench build` | Compile assets | After JS/CSS changes | |
| 14 | | `bench --site SITE console` | Python REPL | Debugging | |
| 15 | | `bench start` | Start dev server | Development | |
| 16 | | `bench setup production` | Configure nginx+supervisor | Deploying to production | |
| 17 | |
| 18 | ## 1. Scaffolding: bench new-app |
| 19 | |
| 20 | ```bash |
| 21 | bench new-app my_custom_app |
| 22 | ``` |
| 23 | |
| 24 | Interactive prompts: |
| 25 | - App Title → Human-readable name |
| 26 | - App Description → One-line summary |
| 27 | - App Publisher → Company/author name |
| 28 | - App Email → Contact email |
| 29 | - App Icon → Default: `octicon octicon-file-directory` |
| 30 | - App Color → Default: `grey` |
| 31 | - App License → Default: `MIT` |
| 32 | |
| 33 | ### Generated Directory Structure |
| 34 | |
| 35 | ``` |
| 36 | apps/my_custom_app/ |
| 37 | ├── MANIFEST.in # Files included in Python package |
| 38 | ├── README.md # Project readme |
| 39 | ├── license.txt # License file |
| 40 | ├── requirements.txt # Python dependencies |
| 41 | ├── dev-requirements.txt # Dev-only Python deps (v15+) |
| 42 | ├── package.json # Node.js dependencies |
| 43 | ├── setup.py # Python package config (v14) |
| 44 | ├── pyproject.toml # Python package config (v15+) |
| 45 | ├── my_custom_app/ |
| 46 | │ ├── __init__.py # App version string |
| 47 | │ ├── hooks.py # Framework integration hooks |
| 48 | │ ├── modules.txt # List of app modules |
| 49 | │ ├── patches.txt # Migration patches list |
| 50 | │ ├── config/ |
| 51 | │ │ ├── __init__.py |
| 52 | │ │ ├── desktop.py # Desktop/workspace config |
| 53 | │ │ └── docs.py # Documentation config |
| 54 | │ ├── public/ # Static assets → /assets/my_custom_app/ |
| 55 | │ │ ├── css/ |
| 56 | │ │ └── js/ |
| 57 | │ ├── templates/ # Jinja templates |
| 58 | │ └── www/ # Portal pages (URL = path) |
| 59 | ``` |
| 60 | |
| 61 | ### What Each Core File Does |
| 62 | |
| 63 | | File | Purpose | NEVER Forget | |
| 64 | |---|---|---| |
| 65 | | `__init__.py` | Defines `__version__` | ALWAYS update before release | |
| 66 | | `hooks.py` | ALL framework integration | Entry point for everything | |
| 67 | | `modules.txt` | Declares app modules | ALWAYS add new modules here | |
| 68 | | `patches.txt` | Migration patch registry | ALWAYS add patches in order | |
| 69 | | `requirements.txt` | Python deps installed on setup | Add pip packages here | |
| 70 | | `public/` | Static files served by nginx | Accessible at `/assets/app_name/` | |
| 71 | | `www/` | Portal pages | Filename = URL path | |
| 72 | |
| 73 | ## 2. Development Cycle |
| 74 | |
| 75 | ``` |
| 76 | Code → Migrate → Build → Test → Commit |
| 77 | ``` |
| 78 | |
| 79 | ### Step-by-Step |
| 80 | |
| 81 | ```bash |
| 82 | # 1. Make code changes (DocTypes, reports, APIs, etc.) |
| 83 | |
| 84 | # 2. Migrate — sync DocType schema + run patches |
| 85 | bench --site mysite migrate |
| 86 | |
| 87 | # 3. Build — compile JS/CSS assets |
| 88 | bench build --app my_custom_app |
| 89 | |
| 90 | # 4. Test — run Python tests |
| 91 | bench --site mysite run-tests --app my_custom_app |
| 92 | |
| 93 | # 5. Commit |
| 94 | git -C apps/my_custom_app add -A && git -C apps/my_custom_app commit -m "feat: add feature" |
| 95 | ``` |
| 96 | |
| 97 | ALWAYS run `bench migrate` after modifying DocType JSON files. |
| 98 | ALWAYS run `bench build` after modifying JS/CSS files. |
| 99 | |
| 100 | ## 3. Getting Apps from Git |
| 101 | |
| 102 | ```bash |
| 103 | # Public repo |
| 104 | bench get-app https://github.com/org/my_app |
| 105 | |
| 106 | # Specific branch |
| 107 | bench get-app https://github.com/org/my_app --branch develop |
| 108 | |
| 109 | # Private repo via SSH |
| 110 | bench get-app git@github.com:org/private_app.git |
| 111 | |
| 112 | # Private repo via token (v15+) |
| 113 | bench get-app https://TOKEN@github.com/org/private_app.git |
| 114 | ``` |
| 115 | |
| 116 | After `get-app`, ALWAYS install on the target site: |
| 117 | ```bash |
| 118 | bench --site mysite install-app my_app |
| 119 | ``` |
| 120 | |
| 121 | `get-app` clones to `apps/` and adds to `apps.txt`. |
| 122 | `install-app` creates database tables and runs `after_install` hooks. |
| 123 | |
| 124 | ## 4. Installing and Removing Apps |
| 125 | |
| 126 | ### Installation Order Matters |
| 127 | Apps are installed in order listed in `apps.txt`. If App B depends on App A, App A MUST be listed first. |
| 128 | |
| 129 | ```bash |
| 130 | # Install |
| 131 | bench --site mysite in |