/cms-cultivator:composer-patch-generatorfrom cms-cultivator
Generates CI-safe patches for Composer-managed packages (Drupal, WordPress, PHP libraries) using cweagans/composer-patches. Handles diff generation, new files, composer.json wiring, and patch verification.
Ships in cms-cultivator. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Generate reliable, CI-safe patches for Composer-managed packages you cannot edit directly (Drupal contrib modules, WordPress plugins/packages, PHP libraries).
Contrib and vendor code is not yours to fork. Patches let you carry a change on
top of an upstream release, re-apply it on every composer install, and drop it
the moment upstream ships a fix.
.git metadata, or tooling files.vendor/ or web/modules/contrib/ directly — those dirs are
git-ignored and rebuilt on install. The patch is the only durable artifact.Activate when the user:
extra.patches in composer.json.Do not use for changes to custom (first-party) modules/themes — edit those directly.
These are the failure modes that cause "works locally, fails on CI":
diff -ruN, NOT git diff. cweagans/composer-patches tries
git apply only when the install dir has a .git folder. CI installs with
--prefer-dist (archives, no .git), so it falls back to the patch
command — which cannot parse git headers (diff --git, new file mode 100644, index abc..def). diff -ruN is universally compatible.git clone. Drupal.org dist
.zip/.tar.gz files differ from the git repo: they add LICENSE.txt and
packaging metadata (version/datestamp lines appended to .info.yml). CI uses
the dist. If you diff against a clone, those files show up as spurious "new
file" hunks that fail when patch finds them already present.--exclude to diff -ruN. It leaks into the header lines
(diff -ruN --ex a/file b/file) and breaks patch parsing. Delete unwanted
dirs (.git, node_modules) before diffing instead.PATCHES.txt written by composer-patches. Never let it into your diff.# Exact installed version (drives which dist archive to download).
grep -E "^version|datestamp" web/modules/contrib/<module>/<module>.info.yml
# Or from the lock file:
grep -A2 '"name": "drupal/<module>"' composer.lock | head -3
# Any patches already applied (yours must stack cleanly on top of these).
grep -A6 '"drupal/<module>"' composer.json
Edit the installed files in place (so you can test live), and diff them against a clean snapshot of the same version.
WORK=/tmp/patch_gen && rm -rf "$WORK" && mkdir -p "$WORK"
# Preferred base = the dist archive CI will use:
curl -sL "https://ftp.drupal.org/files/projects/<module>-<version>.zip" -o "$WORK/dist.zip"
unzip -q "$WORK/dist.zip" -d "$WORK/base_dl" # -> $WORK/base_dl/<module>
cp -r "$WORK/base_dl/<module>" "$WORK/base"
# If earlier patches exist, apply them to the base first so your diff is a
# clean delta ON TOP of them (order matters — composer applies in listed order):
( cd "$WORK/base" && patch -p1 --no-backup-if-mismatch < /path/to/earlier-patch.patch )
If you cannot download the dist (no network, private package), snapshot the current installed dir before you edit as the base — acceptable as long as no uncommitted edits exist yet and no unpatched files you'll touch differ from dist.
Edit files under web/modules/contrib/<module>/ (or vendor/<pkg>/) directly.
Run the project's checks on the changed files (e.g. composer phpcs,
composer phpstan, unit tests) before generating the patch.
diff -ruN# Mirror the edited install into a clean "modified" tree (drop noise + artifacts).
rsync -a --exclude='.git' --exclude='node_modules' \
web/modules/contrib/<module>/ "$WORK/modified/"
rm -f "$WORK/modified/PATCHES.txt" # composer-patches artifact — never patch it
rm -rf "$WORK/base/.git" "$WORK/modified/.git"
# Confirm ONLY the files you intended changed:
diff -qr "$WORK/base" "$WORK/modified"
# Emit the patch, normalizing paths to a/ … b/ (what `patch -p1` expects):
( cd "$WORK" && diff -ruN base/ modified/ \
| sed 's|^--- base/|--- a/|; s|^+++ modified/|+++ b/|; \
s|^diff -ruN base/|diff -ruN a/|; s| modified/| b/|' \
) > patches/<module>-<short-description>.patch
New files are handled automatically by diff -ruN (uses an epoch timestamp on
the --- line), unlike git diff's unparseable new file mode header.
composer.json"extra": {
"patches": {
"drupal/<module>": {
"Short description of the change (link to upstream issue/MR if any)": "patches/<module>-<short-description>.patch"
}
}
}
Patches for one package apply in listed order; each must apply on top of the
previous. If a patch needs a non-default strip level, add
"extra": { "patchLevel": { "drupal/<module>": "-p1" } }.
# a) CI-equivalent dry run on a fresh pristine copy:
cp -r "$WORK/base_dl/<module>" "$WORK/verify"
( cd "$WORK/verify" && patch -p1 --dry-run --no-backup-if-mismatch < patches/<module>-<desc>.patch; echo "exit: $?" )
# b) End-to-end through Composer (definitive):
composer reinstall drupal/<module> --no-interaction
# NOTE: reinstall deletes the dir then reports "Uninstall failed / not installed".
# That is a known cweagans quirk — follow with:
composer install --no-interaction
# Look for: "Applying patches for drupal/<module>" with no errors.
Both must succeed. Re-run the project's lint/tests once more against the freshly patched install to confirm nothing drifted.
Regenerate against a base that has all prior patches applied but not the one you are rewriting. The diff then captures the new delta only. Re-verify with the full stack applied in order.
When done, summarize:
## Composer Patch: <module>-<description>
- Package: drupal/<module> <version> (dist)
- Files changed: <list>
- New files: <list or none>
- composer.json: entry added under extra.patches["drupal/<module>"]
- Verified: patch -p1 dry-run ✅ | composer install "Applying patches" ✅
- Checks: phpcs ✅ | phpstan ✅ | tests ✅
- Upstream: <issue/MR link, or "none — local customization">
git diff format or a .git
dir enabling git apply locally. Regenerate with diff -ruN.composer.json: adding an extra.patches
entry does not change dependency versions, so no composer update is needed;
the warning is benign. Only re-lock if you changed a require.extra.patchLevel.patches/
and the composer.json entry are committed; the module files are not tracked.You: "I need to fix a bug in the drupal/ai contrib module and it has to survive composer install."
Claude: "I'll create a composer patch. First, the installed version and any existing
patches for drupal/ai, then I'll snapshot the pristine dist as the base, apply your
edit, generate a diff -ruN patch, wire it into extra.patches, and verify it applies
via composer install."
You: "My patch applies on my machine but the pipeline says 'Cannot apply patch'."
Claude: "That's the classic git-diff-vs-patch mismatch. CI installs from dist archives
with no .git dir, so composer-patches falls back to the `patch` command, which can't
read git headers. Let me regenerate it in diff -ruN format based on the dist archive."
patch(1) and diff(1) man pagesWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
cms-cultivator@claude-toolbox is listed by kanopi/claude-toolbox — review the source before installing
npx claudepluginhub kanopi/claude-toolbox --plugin cms-cultivator30 skills in this plugin
/browser-validatorAutomatically validate implementations in real browsers after code is written or when user says "test this", "test what you built in the browser", "check it in a real browser", or "validate at the breakpoints". Uses Chrome DevTools MCP to test responsive breakpoints (320px, 768px, 1024px), check accessibility compliance (WCAG AA contrast, keyboard navigation, ARIA), validate interactions, and generate detailed technical reports with file paths and specific fixes./code-standards-checkerRun the right linting, formatting, and static-analysis commands after changing code, and check it against PHPCS, ESLint, WordPress Coding Standards, or Drupal Coding Standards. Reads the scripts blocks in composer.json and package.json to find the project's own commands, runs auto-fix before check-only and verifies after, and picks the most specific level (theme, plugin, module, or project root) covering the changed files. Invoke when the user mentions "coding standards", "code style", "linting", "lint", "PHPCS", "phpcbf", "PHPStan", "Rector", "ESLint", "stylelint", "twig-lint", asks what to run after editing PHP, Twig, JS, SCSS, or CSS, or asks whether code follows conventions./commit-message-generatorAutomatically generate conventional commit messages when user has staged changes and mentions committing. Analyzes git diff and status to create properly formatted commit messages following conventional commits specification. AI attribution comes from the tool's own trailer (Claude Code's Co-Authored-By); the skill never adds a second one. Invoke when user mentions "commit", "staged", "committing", or asks for help with commit messages./composer-security-updateThis skill should be used when the user asks to "run a Composer security update", "validate the security PR", "check the automated security PR", "run composer audit", "patch the security advisories", "update the vulnerable packages", "fix the CVEs in this project", "apply the Drupal core security release", or hands over a "Security Advisory:" Teamwork task or a `security/tw-*` pull request. Use it whenever a Drupal or WordPress Composer project needs its advisories resolved, even if the user only says "are we vulnerable?" or names a single CVE. It finds the PR the Kanopi security dashboard already opened, validates its branch locally (composer audit before and after, DDEV snapshot and refresh, update hooks, config drift, theme builds), and reports each advisory as cleared or blocked. Fix-ups and the PR update wait for user approval. It never creates a task, branch, or PR. Dependabot bumps belong to dependabot-branch-validation; patching contrib code belongs to composer-patch-generator./coverage-analyzerAutomatically analyze test coverage when user asks which code is tested, mentions coverage gaps, or shows code asking about testing. Identifies untested code paths and suggests test additions. Invoke when user asks "what's not tested?", "coverage", "untested code", or "which tests are missing?"./ddev-docker-cleanupDeterministic cleanup of DDEV and Docker disk usage on OrbStack, Docker Desktop, or any Docker provider. Safely reclaims space by removing orphaned Docker volumes (leftovers from worktrees, agent or CI runs, Playwright tests, and throwaway clones), build cache, and dangling images, while protecting the database of every current DDEV project. Use this whenever the user is low on disk or memory, mentions DDEV, Docker, or OrbStack taking up space, sees many "unused" volumes, wants to prune Docker, or asks how to clean up their local dev environment, even if they do not say the word "skill."Other plugins' skills for the same job