Skip to content

Commit 9308c54

Browse files
authored
Merge pull request #5 from JUVOJustin/add-skill-reference-docs
Add reference docs for WordPress Multisite and npm projects in DDEV
2 parents 9f1e5a4 + 7e96a12 commit 9308c54

4 files changed

Lines changed: 506 additions & 127 deletions

File tree

skills/ddev/SKILL.md

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,33 @@ ddev yarn add <pkg> # runs yarn inside the container
2222
ddev php -v # runs PHP inside the container
2323
```
2424

25-
For the full list of shortcuts and their mappings, see [references/commands.md](references/commands.md).
25+
For the full list of shortcuts and their mappings, run `ddev help`.
2626

27-
## Executing CLI Commands (Step-by-Step)
27+
## DDEV Commands Work from Any Subdirectory
2828

29-
Always follow these steps before running any CLI tool (composer, npm, wp, drush, yarn, phpunit, etc.) in a DDEV project:
29+
DDEV automatically detects its project root from any subdirectory within the project tree. Most DDEV commands work out of the box regardless of where the shell is located:
3030

31-
### Step 1: Resolve the correct container path
31+
```bash
32+
ddev wp plugin list
33+
ddev mailpit
34+
ddev db
35+
ddev composer show
36+
ddev npm ls
37+
ddev drush cr
38+
ddev start
39+
ddev describe
40+
ddev ssh
41+
```
42+
43+
No special flags or path resolution is needed for these commands.
44+
45+
## When `--dir` Scoping IS Required
3246

33-
Determine whether the working directory is the DDEV project root or a subdirectory. Run the bundled resolve script:
47+
The `--dir` flag is only needed when running **file-path-sensitive scripts** via `ddev exec` that must target a specific subdirectory inside the container. This applies when the command operates on files relative to the working directory (e.g., `composer install` reading a specific `composer.json`, or `npm install` reading a specific `package.json`).
48+
49+
### Step 1: Resolve the container path
50+
51+
Run the bundled resolve script to map the host subdirectory to a container path:
3452

3553
```bash
3654
scripts/resolve-ddev-root.sh "$(pwd)"
@@ -46,40 +64,33 @@ Output (JSON):
4664
}
4765
```
4866

49-
- `relative_path` **empty** -- working directory is the DDEV root, shortcuts work directly.
50-
- `relative_path` **non-empty** -- working directory is a subdirectory, use `--dir` with the `container_path` value in all commands.
67+
- `relative_path` **empty** -- working directory is the DDEV root, no `--dir` needed.
68+
- `relative_path` **non-empty** -- use `--dir` with the `container_path` value for file-path-sensitive commands.
5169

52-
### Step 2: Execute command
70+
### Step 2: Execute the scoped command
5371

5472
If DDEV is not running, start it first with `ddev start`.
5573

56-
**At the project root** (relative_path is empty) -- use DDEV shortcuts:
57-
58-
```bash
59-
ddev composer install
60-
ddev npm run build
61-
ddev wp plugin list
62-
ddev yarn add <pkg>
63-
```
64-
65-
**From a subdirectory** (relative_path is non-empty) -- use `ddev exec --dir`:
66-
6774
```bash
75+
# Install dependencies scoped to a plugin subdirectory
6876
ddev exec --dir="/var/www/html/wp-content/plugins/my-plugin" bash -c "composer install"
69-
ddev exec --dir="/var/www/html/wp-content/plugins/my-plugin" bash -c "wp plugin activate my-plugin"
77+
ddev exec --dir="/var/www/html/wp-content/plugins/my-plugin" bash -c "npm install"
78+
79+
# Run a script that reads files relative to the working directory
80+
ddev exec --dir="/var/www/html/wp-content/plugins/my-plugin" bash -c "phpunit"
7081
```
7182

72-
The `--dir` flag is required whenever the target directory differs from the container docroot (`/var/www/html`). Without it, commands run at the docroot and may operate on the wrong `composer.json`, `package.json`, or project context.
83+
Without `--dir`, these commands run at the container docroot (`/var/www/html`) and operate on the wrong `composer.json`, `package.json`, or project context.
7384

7485
## Running Commands in Containers
7586

76-
Use `ddev exec` when a shortcut does not exist or when targeting a specific directory:
87+
Use `ddev exec` when no shortcut exists or when you need to target a specific container directory:
7788

7889
```bash
79-
# Default: runs in web container at docroot
90+
# Runs in web container at docroot
8091
ddev exec ls -la
8192

82-
# Specify a working directory inside the container
93+
# Scope to a subdirectory for file-path-sensitive operations
8394
ddev exec --dir="/var/www/html/wp-content/plugins/my-plugin" bash -c "composer install"
8495

8596
# Run in the database container
@@ -89,15 +100,9 @@ ddev exec -s db mysql -e "SHOW DATABASES"
89100
ddev . ls -la
90101
```
91102

92-
Use `ddev ssh` for an interactive shell session.
93-
94-
## Subpath Mapping (Working from a Subdirectory)
95-
96-
A common scenario: the DDEV project is configured for a full application (e.g., a WordPress site at `~/Projects/mysite/`) but the agent runs from a subdirectory (e.g., `~/Projects/mysite/wp-content/plugins/my-plugin/`).
97-
98-
### The Problem
103+
## Subpath Mapping (for `ddev exec --dir`)
99104

100-
DDEV commands must reference container paths relative to `/var/www/html` (the container docroot). When the working directory is a subdirectory of the DDEV project, the container path must be computed.
105+
Path resolution is only needed when using `ddev exec --dir` to scope file-path-sensitive scripts to a subdirectory. Standard DDEV commands (`ddev wp`, `ddev mailpit`, `ddev db`, `ddev start`, etc.) do **not** require this -- they work from any subdirectory automatically.
101106

102107
### Resolving the DDEV Root
103108

@@ -151,4 +156,5 @@ Example JSON output fields:
151156
- **resolve-ddev-root.sh** - Walks up the directory tree to find the DDEV project root from any subdirectory. Returns JSON with project root, container path, relative path, and project name.
152157

153158
### references/
154-
- **commands.md** - Quick-reference table of all DDEV CLI shortcuts, lifecycle commands, database tools, and debugging commands.
159+
- **npm-projects.md** - Running npm/Node.js dev servers in DDEV, including port exposure, host binding, and framework-specific examples for Vite, Next.js, and Astro.
160+
- **wordpress-multisite.md** - Setup guide for WordPress Multisite with DDEV, covering subdomains, different hostnames, and subdirectory configurations with WP-CLI commands.

skills/ddev/references/commands.md

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)