Enable Cursor Parallel Agents in your Drupal project with one command.
Cursor Parallel Agents run in isolated Git worktrees with separate DDEV environments. This installer configures everything automatically.
cd your-drupal-project
curl -sL https://raw.githubusercontent.com/droptica/cursor-parallel-agents-for-drupal/main/install.sh | bashThat's it! The installer will:
- Detect if your project is singlesite or multisite
- Install appropriate configuration files
- Auto-configure multisite (sites, databases, sites.php)
- Create database snapshots
- Update AGENTS.md with worktree instructions
- DDEV installed and configured
- Git repository initialized
- Drupal project with
web/ordocroot/structure
# Force project type
curl -sL .../install.sh | bash -s -- --type=multisite
# Dry-run (see what would be installed)
curl -sL .../install.sh | bash -s -- --dry-run
# Show help
curl -sL .../install.sh | bash -s -- --help.cursor/
├── worktrees.json # Cursor worktree config
├── setup-worktree.sh # Setup script for new worktrees
├── cleanup-worktree.sh # Cleanup script
├── README.md # Documentation
├── lib/
│ └── logging.sh # Shared logging functions
└── logs/ # Created automatically
└── worktree-{ID}.log # Logs per worktree
.ddev/commands/host/
├── export-snapshot # Export database for worktrees
└── worktree-status # Show active worktrees
AGENTS.md # AI agent instructions (created/updated)
Same as singlesite, plus:
lib/prerequisites.sh- Validates snapshots before setupexport-multisite-snapshots- Exports all site databasessites.php- Automatically patched with worktree patterns
Each worktree setup creates a log file in .cursor/logs/:
.cursor/logs/
├── worktree-abc12.log # Log for worktree abc12
├── worktree-xyz99.log # Log for worktree xyz99
└── ...
Log files contain:
- Setup progress - each step with timestamp
- DDEV status - start, database import, cache clear
- Site URL - where the worktree site is running
- Admin login URL - one-time login link
- Errors - if something fails
Example log entry:
Dec 17 05:35:07 hostname worktree[12345]: [INFO] Worktree ID: abc12
Dec 17 05:35:07 hostname worktree[12345]: [INFO] Project name: myproject-abc12
Dec 17 05:35:40 hostname worktree[12345]: [OK] DDEV started
Dec 17 05:35:42 hostname worktree[12345]: [INFO] Site URL: https://myproject-abc12.ddev.site
┌─────────────────────────────────────────────────────────────────────┐
│ 1. Cursor creates worktree │
│ └─ Isolated Git branch + files in separate directory │
├─────────────────────────────────────────────────────────────────────┤
│ 2. setup-worktree.sh runs automatically │
│ ├─ Creates fresh database snapshot from main project │
│ ├─ Creates unique DDEV project (e.g., myproject-a8Xk2) │
│ ├─ Generates config.local.yaml with unique hostname │
│ ├─ Runs composer install (if vendor/ missing) │
│ ├─ Builds theme assets (npm/yarn/ddev theme) │
│ ├─ Symlinks files directory from main project │
│ └─ Imports database snapshot │
├─────────────────────────────────────────────────────────────────────┤
│ 3. Agent works in isolated environment │
│ ├─ Separate DDEV containers │
│ ├─ Separate database │
│ └─ Shared files (via symlink) │
├─────────────────────────────────────────────────────────────────────┤
│ 4. Apply changes │
│ └─ Merge worktree branch back to main │
└─────────────────────────────────────────────────────────────────────┘
The worktree setup automatically detects and builds theme assets. Supported methods (checked in order):
| Method | Detection | Command |
|---|---|---|
| ddev theme | Custom DDEV command exists | ddev theme |
| gulp | gulpfile.js in theme |
yarn/npm install && gulp compile/dist |
| npm scripts | package.json in theme |
yarn/npm install && npm run build |
gulp compilegulp distgulp buildgulp(default)
The script searches for package.json in:
web/themes/custom/*/package.jsonthemes/custom/*/package.json
For best results, add a custom DDEV command in .ddev/commands/web/theme:
#!/bin/bash
## Description: Build theme assets
## Usage: theme
## Example: ddev theme
cd /var/www/html/web/themes/custom/your_theme
npm ci && npm run buildThis is the recommended approach as it's portable across all environments.
| Resource | Per Worktree |
|---|---|
| RAM | ~500MB |
| Disk | ~50MB (symlinked files) |
| Setup time | 30-60s |
Recommended: Max 3 concurrent worktrees.
Configure in .cursor/settings.json:
{
"cursor.worktreeMaxCount": 3,
"cursor.worktreeCleanupIntervalHours": 2,
"git.showCursorWorktrees": true
}Tip: Enable
git.showCursorWorktreesto visualize Cursor-created worktrees in the SCM Pane.
# Check worktree status
ddev worktree-status
# Export database snapshot (singlesite)
ddev export-snapshot
# Export all snapshots (multisite)
ddev export-multisite-snapshots
# Cleanup orphaned worktrees
.cursor/cleanup-worktree.sh --allEach worktree gets a unique URL:
| Environment | URL Pattern |
|---|---|
| Main Project | https://myproject.ddev.site |
| Worktree (a8Xk2) | https://myproject-a8Xk2.ddev.site |
For multisite, each site also gets a unique URL:
| Site | Main | Worktree |
|---|---|---|
| Default | https://myproject.ddev.site |
https://myproject-a8Xk2.ddev.site |
| PL | https://pl.myproject.ddev.site |
https://pl.myproject-a8Xk2.ddev.site |
When working as a Parallel Agent in a worktree:
- Complete your work
- Commit and push:
git add -A git commit -m "[type]: description" git push origin HEAD - Create PR for code review
The installer automatically detects and configures multisite projects:
- Detects site directories from
web/sites/(e.g.,pl.example.com) - Detects additional hostnames from
.ddev/config.yaml - Detects database names from
.ddev/config.yamlhooks - Generates
setup-worktree.shwith detected configuration - Generates
export-multisite-snapshotswith all database exports - Patches
sites.phpwith worktree pattern matching - Exports all database snapshots automatically
No manual configuration required in most cases!
Site Directories: Scans web/sites/ for directories with dots (e.g., pl.example.com), excluding default, all, simpletest.
Hostnames: Extracted from .ddev/config.yaml:
additional_hostnames:
- pl.myproject
- de.myprojectDatabases: Extracted from hooks:
hooks:
post-start:
- exec: mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS pl;"If auto-detection doesn't match your setup, edit .cursor/setup-worktree.sh:
SITES=(
"default"
"pl.example.com"
"de.example.com"
)
DB_NAMES=(
"db"
"pl"
"de"
)
FILES_DIRS=(
"${WEB_ROOT}/sites/default/files"
"${WEB_ROOT}/sites/pl.example.com/files"
)Install DDEV: https://ddev.readthedocs.io/en/stable/users/install/
# macOS
brew install ddev/ddev/ddev
# Linux
curl -fsSL https://ddev.com/install.sh | bashInitialize DDEV:
ddev config --project-type=drupal10 --docroot=web
ddev startgit init
git add -A
git commit -m "Initial commit"Snapshots are created automatically during installation. This error occurs only if:
- Snapshots were manually deleted
- You need to refresh after database changes
Recreate snapshots:
ddev export-snapshot # singlesite
ddev export-multisite-snapshots # multisiteThese scripts should only be run by Cursor, not manually.
ddev stop --all
ddev start# Restart Docker, then:
ddev delete -O
ddev start# Check snapshot exists and isn't corrupted
ls -la .ddev/db-dumps/
gunzip -t .ddev/db-dumps/*.sql.gz
# Try manual import
ddev import-db --file=.ddev/db-dumps/yourproject.sql.gz- Check
sites.phphas worktree patterns:grep "worktree_pattern" web/sites/sites.php - Verify site directory exists in
web/sites/ - Clear cache:
ddev drush cr
- Check
sites.phppatterns don't overlap - Verify pattern order (more specific first)
- Check DDEV creates databases in
post-starthook - Ensure snapshot exists:
ls .ddev/db-dumps/ - Re-export:
ddev export-multisite-snapshots
ddev list
.cursor/cleanup-worktree.sh --all
# Or manually: ddev stop myproject-a8Xk2 && ddev delete -O myproject-a8Xk2git worktree list
git worktree remove /path/to/worktree --force
git worktree prune.cursor/cleanup-worktree.sh --all
docker system prune -a- Use SSD storage
- Reduce database size
- Limit concurrent worktrees (max 2-3)
- Reduce
cursor.worktreeMaxCountto 2 - Stop unused worktrees
- Increase system RAM
- Check DDEV logs:
ddev logs - Check Docker logs:
docker logs ddev-myproject-web - Open an issue: https://github.com/droptica/cursor-parallel-agents-for-drupal/issues
cursor-parallel-agents-for-drupal/
├── install.sh # Main installer script
├── README.md # This file
├── LICENSE # MIT License
└── templates/
├── common/ # Shared templates (logging, cleanup, worktrees.json)
├── singlesite/ # Singlesite-specific (setup-worktree, export-snapshot)
└── multisite/ # Multisite-specific (README, worktree-status)
Note: Multisite setup-worktree.sh, prerequisites.sh, and export-multisite-snapshots are generated dynamically by the installer based on detected configuration.
Issues and PRs welcome!
MIT License - see LICENSE
Built with ❤️ by Droptica 🇵🇱
Solid Open Source solutions for ambitious companies.
What we do:
- Create: Open Intranet, Droopler CMS, Druscan
- AI Development: AI chatbots (RAG), autonomous agents, OpenAI/Claude integrations, custom AI models, CMS content automation & translation, workflow automation
- Customize: Drupal, Mautic, Sylius, Symfony
- Support & maintain: Security, updates, training, monitoring 24/7
Trusted by: Corporations • SMEs • Startups • Universities • Government