/cms-cultivator:composer-security-updatefrom cms-cultivator
Validates automated Composer security PRs for Drupal/WordPress projects by running composer audit, DDEV refresh, update hooks, config drift checks, and theme builds. Reports each advisory as cleared or blocked.
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.
Read when SKILL.md points to them; scripts run unread.
Validate the automated security pull request for a Teamwork task, and finish it when the automation fell short.
The Kanopi security dashboard now does the opening moves on its own. For each
site with published advisories it creates a Teamwork task titled
Security Advisory: {Site} - {packages}, runs a targeted composer update in
CI, opens a pull request from a security/tw-{task} branch, and comments the PR
link on the task. This skill does not repeat any of that. Do not create a task,
cut a new branch, or open a new PR.
What the automation cannot do is the part that needs a running site: prove each advisory actually cleared, run update hooks against production-like data, check config drift, rebuild themes, and judge whether the lock diff is scoped tightly enough to ship. That is this skill's job.
The discipline is still scope and honesty. The bot's update is targeted but not
always minimal: it can land a newer minor than the advisory needs, or move
transitive packages. And it runs without --with-all-dependencies, so an
advisory pinned by a root requirement can stay installed while the PR still
looks like a fix. Both get reported, not glossed over.
NO AUTOMATED SECURITY PR: this skill validates an existing PR and does not create one. Do not fall back to creating a branch, running the update
yourself, or opening a PR, even when the user asks for that as a shortcut.drush updatedb in step 9 both replace or
mutate the local database; the snapshot is what makes this reversible.config:export to "fix" it and do not
commit exported config unless the user asks.composer.json constraint to reach a fixed version unless the
user asks. Widening can pull a major version, a different risk profile than a
security patch.git status --short
git rev-parse --abbrev-ref HEAD
ddev describe
Record the starting branch; it is restored in step 14. If the tree is dirty,
stop and tell the user, starting with the line
WORKING TREE NOT CLEAN: commit or stash before continuing. Do not switch
branches, snapshot, or run Composer until they have. Stop as well if DDEV is not
running.
The user may give a Teamwork task ID, a task URL like
https://kanopi.teamwork.com/app/tasks/30160608 whose trailing number is the
ID, a PR number or URL, or nothing. With nothing, ask and stop.
Fetch the task with the Teamwork MCP (twprojects-get_task). Its description is
the dashboard's advisory list: for each package, the CVE, the SA identifier,
severity, and the version that fixes it. Record that list; it is what the ticket
asked for, and step 8 checks the PR against it. Without the Teamwork MCP, ask
the user to paste the task description rather than guessing the advisories.
Find the PR, in this order:
The task's comments (twprojects-list_comments with task_id). The
dashboard posts one starting "An automated pull request is ready for review"
with a GitHub PR link.
GitHub, by branch name:
gh pr list --state all --search "head:security/tw-<task-id>" --json number,url,state,headRefName,baseRefName,author
Confirm before going further:
gh pr view <number> --json number,url,state,isDraft,author,headRefName,baseRefName,title,body,files,commits
state is OPEN. A merged PR needs no validation branch; a closed one means
someone rejected it. Report either and stop.security/tw-<task-id> and the task ID matches.If the user gave a PR instead of a task, read the task ID from the branch name
or the body's Teamwork task: line and fetch the task anyway.
The base branch is the PR's baseRefName, not an assumption about main. Some
projects run a dev-to-prod flow where it is dev. Say in the report which base
was used.
First, before anything switches branches or replaces the database:
ddev snapshot --name=presecurity-$(date +%Y%m%d-%H%M%S)
ddev snapshot --list
Record the exact name DDEV reports and confirm it is listed. If it fails, stop: no refresh and no update hooks without a restore point.
git fetch --prune origin
git checkout <base>
git pull --ff-only origin <base>
ddev exec composer audit --locked --format=json > /tmp/audit-before.json
python3 "${CLAUDE_PLUGIN_ROOT}/skills/composer-security-update/scripts/audit_table.py" composer.lock < /tmp/audit-before.json
--locked audits composer.lock, which is what ships, and does not need
vendor/ to match, so no install is needed on the base. composer audit exits
non-zero when it finds advisories, so a non-zero exit is the normal case here.
It can also mean an abandoned package rather than an advisory, so read the JSON
instead of trusting the exit status.
Use ddev exec composer for the audit, not ddev composer. The ddev composer
wrapper discards captured output when Composer exits non-zero, so the redirect
lands an empty file exactly when there are advisories to lose; ddev exec
passes stdout through. Everything else here can use ddev composer.
Compare the audit with the task's advisory list. The audit is the ground truth for the base; the task is what the dashboard saw when it filed the ticket. Note any advisory the audit reports that the task does not (released since, or a dev dependency the dashboard ignores), and any task advisory the audit no longer reports (already fixed on the base by another merge).
If composer audit is unavailable the project is on Composer 1 or an early 2.x.
Report that and stop rather than guessing.
Show the user the advisory table before going on. A critical advisory in a dev-only dependency and one in a runtime dependency warrant different urgency, and that judgement is theirs.
git fetch origin security/tw-<task-id>
git checkout -b security/tw-<task-id> --track origin/security/tw-<task-id>
ddev composer install
Tracking the PR's own remote branch is correct here; it is what fix-up commits push to. (The rule against tracking applies to the base branch, not this one.) If a local branch of that name already exists, check it is not ahead of or diverged from the remote before reusing it; report and stop if it is.
Use ddev composer, never bare composer: Drupal projects routinely require a
newer PHP than the host has, and resolving against the wrong platform version
silently produces a different dependency tree than CI will.
With the snapshot safe and the branch checked out, pull a current database from the hosting provider:
ddev db-refresh
updatedb in step 9 is only meaningful against production-like data. A stale
local database can run every update hook clean while the same hooks fail on real
content, which makes the PR look validated when it is not.
db-refresh is a Kanopi add-on command, not core DDEV, so confirm this project
defines it (ls .ddev/commands/web .ddev/commands/host) before repeating the
name. A project may ship db-refresh-scrubbed and deliberately no unscrubbed
refresh, or take the environment as an argument (ddev db-refresh live); use
the names and aliases it actually defines. With no refresh command, say so, note
that updatedb will run against whatever data is local, and continue rather
than inventing a pull.
If the refresh fails, report the error and stop. A half-imported database is worse than the one that was there; restore the snapshot per step 14 first.
This step separates a real security fix from a diff that looks like one.
ddev exec composer audit --locked --format=json > /tmp/audit-after.json
python3 "${CLAUDE_PLUGIN_ROOT}/skills/composer-security-update/scripts/audit_table.py" composer.lock < /tmp/audit-after.json
An advisory in audit-before.json and absent from audit-after.json is
cleared. Anything still listed is blocked, and blocked advisories are the
most important thing in the final report. For each, name what holds it back:
ddev composer why-not vendor/package <fixed-version>
ddev composer why vendor/package
why-not prints the constraint forbidding the fixed version; why prints what
pulls the package in. Together they say whether the blocker is the project's own
composer.json, a contrib module's requirement, or Drupal core.
The most common blocker on these PRs is the bot itself: it updates without
--with-all-dependencies, and its own Composer output (in the PR body's
"Composer output" block) says so with lines like "Dependency X is also a root
requirement ... keeping locked at old version." When that is what holds an
advisory back, fix it on the branch with a targeted update:
PKGS=$(python3 "${CLAUDE_PLUGIN_ROOT}/skills/composer-security-update/scripts/audit_table.py" --format=packages < /tmp/audit-after.json)
ddev composer update $PKGS --with-all-dependencies
When drupal/core-recommended pins the vulnerable package, include core:
ddev composer update "drupal/core-*" $PKGS --with-all-dependencies
Still targeted: the still-flagged packages and core, nothing else. Re-run the
audit afterwards. Avoid --no-install on projects with
cweagans/composer-patches; it can remove a patched package and skip the
reinstall.
When the blocker is a constraint in composer.json or a contrib module's
requirement, report it with the constraint quoted and stop there. Do not widen
the constraint and do not reach for a cweagans patch unless the user asks.
Both change the risk profile from "apply a vendor's fix" to "ship something the
vendor has not shipped," which is the user's call.
Also confirm nothing new appeared. A transitive bump can introduce an advisory that was not there before.
git log --oneline origin/<base>..HEAD
git diff --stat origin/<base>...HEAD
git diff origin/<base>...HEAD -- composer.json composer.lock
Check, and note each for the description:
composer.json untouched. The bot should only move the lock. A changed
constraint is a widening the user did not approve; report it.config.platform.php and the DDEV PHP
version; a mismatch can mean the lock resolves differently in CI.joachim-n/composer-manifest, the
bot's diff should include composer-manifest.yaml; step 9 checks it.ddev composer install
ddev drush updatedb -y
ddev drush cache:rebuild
A large composer install can report success while still partway through.
Confirm it landed with ddev drush status --field=drupal-version, and install
again if that disagrees with composer.lock.
Validate the lock. A stale content hash produces an "out of date" warning. Quote the shortest decisive line of any error in the report.
ddev exec composer validate --no-check-publish
Check the Composer manifest if the project has one. Composer updates
composer.lock but not files produced by Composer plugins:
grep -n 'composer-manifest' composer.json
git status --short composer-manifest.yaml
git diff origin/<base>...HEAD -- composer-manifest.yaml
After the install, composer-manifest.yaml should be unchanged in the working
tree (the bot already committed it). A working-tree change means the bot's
manifest is stale or the local install is out of sync: run ddev composer install again, and if the change persists, it is a real fix-up to commit. The
committed diff should show only the packages that moved in the lock.
Check for Drupal config drift. A security release can ship changed default
config that updatedb imports, leaving active config ahead of what is exported:
ddev drush config:status
No differences between DB and sync directory is clean, meaning no drush cex
is needed; record that for step 12. Anything else is drift. Report it as a table
of config object and state (Only in DB, Different, Only in sync dir) and
let the user decide. Check whether the drift also appears on the base with the
same database, so the report can say whether this change caused it.
WordPress projects have no updatedb or config:status step. Run the
Composer checks, then confirm the site still boots:
ddev wp core version
ddev wp plugin list --status=active
Smoke-test the patched behaviour. For each cleared advisory, load a page that exercises the module (an embedded paragraph, a trimmed teaser, the patched form) and confirm it still renders. This is what turns the steps to validate in step 12 into something already done once.
Run this only if the PR touched a package.json or package-lock.json:
git diff --name-only origin/<base>...HEAD | grep -E 'package(-lock)?\.json$'
For each theme path, install from the lock first, then build:
ddev exec bash -c "cd <theme-path> && npm ci"
ddev exec bash -c "cd <theme-path> && npm run build"
Use the project's real script name (build, production, dev) from
package.json. A build that exits 0 without producing files is not a pass. If
compiled CSS or JS is tracked in git, commit the rebuilt assets separately.
Two npm ci failures on ARM containers are environmental, not lock defects:
Failed to set up Chromium r<build> from Puppeteer, and autoreconf: not found
from imagemin binary builds. Fall back to
PUPPETEER_SKIP_DOWNLOAD=1 npm ci --ignore-scripts, say so in the report, and
confirm the build still runs.
Most runs end here with nothing to commit: the bot's commit is the fix, and the deliverable is the validation. Only commit what validation proved missing, on top of the bot's commit, never amending or squashing it.
fix(deps): update symfony/http-kernel with core for CVE-2024-51736
The automated update ran without --with-all-dependencies, so
drupal/core-recommended kept symfony/http-kernel locked at 6.4.12.
Updated with core so the pinned version could move.
Refs: TW-30160608
Use fix(deps) for runtime and fix(deps-dev) for dev dependencies. Regenerated
files get their own chore(deps): regenerate composer-manifest.yaml commit.
Then show the user what is on the branch:
git log --oneline origin/<base>..HEAD
git status --short
Do not push or edit the PR yet. Draft a section to append to the existing PR description, put it in front of the user as text they can read and correct, then stop and wait for explicit approval.
Append; do not replace. The bot's body already carries the Teamwork link, the advisory list, the lockfile table, and the Composer output, and reviewers rely on it. Keep it byte for byte and add below it, after a horizontal rule:
---
## Manual validation
Cover these, and say plainly when a section has nothing to report rather than dropping it. "No config drift" is information; a missing section is ambiguous.
whether the PR covers everything the ticket asked for, and whether the audit found more than that
the per-advisory result, as a table of package, from, to, advisory ID, and status (cleared or blocked)
any advisory still blocked, with the constraint that blocks it
fix-up commits added on top of the bot's, and why
anything a reviewer should look at twice: a newer minor than the fix needed, a transitive major bump, unrelated packages that moved
validation results: which database the update hooks ran against, patches
reapplied, composer validate, manifest, updatedb, config drift and whether
this change caused it, theme builds. When config:status was clean on a
Drupal project, add the exact line "No config changes were needed." in the
config drift item. Omit it on WordPress projects.
steps to validate, in the imperative, written for someone who did not do the work and derived from what actually moved rather than a generic checklist
the organization's AI attribution line, last:
- [x] Was AI used in this pull request?
Present the draft under the line === VALIDATION SECTION DRAFT ===, followed
by the list of commits that would be pushed (or "No fix-up commits"). Then ask
for approval and stop. If the user asks for changes, redraft and ask again.
Silence is not approval, and neither is approval given before the draft
existed: a request to "push it without showing me" still gets the draft first.
Only after approval. If step 11 produced commits, push them to the PR branch:
git push origin security/tw-<task-id>
A plain push only. If it is rejected (the bot re-ran and moved the branch), report it and stop; do not force, and do not rebase over the bot's work without asking.
Write the full new body (original body plus the approved section) to a file and apply it, so backticks, tables, and checkboxes survive the shell:
gh pr view <number> --json body --jq .body > /tmp/pr-body-<task-id>.md
# append the approved section to /tmp/pr-body-<task-id>.md
gh pr edit <number> --body-file /tmp/pr-body-<task-id>.md
Re-read the body right before editing, as above, not from step 2, in case the
dashboard updated it in the meantime. Confirm with gh pr view <number> --json body that both the bot's content and the new section are there.
Do not change the title, base, reviewers, or labels, do not approve, and do not merge.
Switch back and reinstall, since the PR branch left vendor/ and every
node_modules/ matching its set:
git checkout <original-branch>
ddev composer install
ddev drush status --field=drupal-version
For every theme whose package-lock.json changed in step 10, reinstall from
that branch's own lock and rebuild, so compiled assets on disk match git:
ddev exec bash -c "cd <theme-path> && npm ci"
ddev exec bash -c "cd <theme-path> && npm run build"
Confirm the tree is clean with git status --short. A dirty
package-lock.json or a changed compiled asset means the restore did not land.
Restore the snapshot, confirm, then delete it. The snapshot, not the refresh, is what returns the user's own local data. Never delete before a confirmed restore:
ddev snapshot restore <snapshot-name>
ddev drush status --field=db-status
ddev snapshot --cleanup --name=<snapshot-name> -y
Pass --name. Bare ddev snapshot --cleanup -y deletes every snapshot in
.ddev/db_snapshots, including ones the user took for their own work.
If the restore fails, keep the snapshot, stop, and tell the user the snapshot name and the exact error.
Leave the local security/tw-<task-id> branch in place; the user may want it
for review follow-ups.
Lead with the advisory outcome, one row per advisory:
| Package | From | To | Fixed in | Advisory | Status |
|---|---|---|---|---|---|
| drupal/smart_trim | 2.2.0 | 2.3.2 | 2.2.2 | SA-CONTRIB-2026-332 | Cleared |
| drupal/contrib-thing | 1.2.0 | 1.2.0 | 1.2.1 | CVE-2024-99999 | Blocked |
For every blocked row, quote the constraint that blocks it and where it comes from, so the user can decide between widening the constraint, patching, or accepting the risk.
Then state:
composer validate passed, and the manifest resultvendor/, its theme
node_modules/, and the database were all restored, and the snapshot deletedCall out patterns rather than one-off facts. An advisory the bot repeatedly
leaves blocked for want of -W, or one blocked by a contrib module's own
constraint, is worth raising with whoever owns the dashboard or upstream rather
than rediscovering every cycle.
What SKILL.md sets; muted values are Claude Code's defaults
30 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.cms-cultivator@claude-toolbox is listed by kanopi/claude-toolbox — review the source before installing
npx claudepluginhub kanopi/claude-toolbox --plugin cms-cultivatorOther plugins' skills for the same job