drupal-security — Claude Code skill: secure Drupal code
A coding-agent skill that nudges you toward safe Drupal patterns: parameterized queries, escaped output, permission checks. It activates on its own while you write forms, controllers or handle user input.
npx skills add madsnorgaard/drupal-agent-resources --skill drupal-security -a claude-codeWhat drupal-security does
The skill fires automatically when the agent writes or edits forms, controllers or plugins, builds database queries, or handles user input. It warns during the edit, not after the commit.
Inside is a walkthrough of the usual holes: string concatenation in SQL, output through #markup, accessCheck(FALSE) on entity queries, routes missing _permission, {{ var|raw }} in Twig, hardcoded passwords and keys. Each one comes with a safe alternative: the query builder with condition(), placeholders like :name, #plain_text, Xss::filterAdmin(), CSRF tokens for AJAX. File uploads get their own section — check the MIME type, not just the extension.
There is a pre-commit checklist and a red-flag table listing the pattern, the risk and the fix. The skill also suggests four questions for any code: where the data comes from, where it goes, who should reach it, and what happens with malicious input. Treat it as a nudge while you type, not a replacement for a security audit.
Install is one command through npx skills add.
What it helps with
- Catches XSS, SQL injection and access bypass while the code is being written instead of at review time.
- Gives safe replacements for common Drupal anti-patterns: query builder over concatenation,
#plain_textover#markup,accessCheck(TRUE)overFALSE. - Ships a pre-commit checklist and a red-flag table you can run against someone else's code.
Example prompts for the agent
- Install the skill, then ask the agent to write a form or controller — it pulls in the safe patterns on its own.
- During review, ask: "check this code for SQL injection and XSS against Drupal rules".
- Ask "how do I safely render user HTML in Drupal?" and the skill points to
Xss::filterAdmin()and the right render elements.
How to install drupal-security
1Skills CLI (Vercel)
npx skills add madsnorgaard/drupal-agent-resources --skill drupal-security -a claude-code2Manually: put the files in place
~/.claude/skills/drupal-security/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/drupal-security/
1Skills CLI (Vercel)
npx skills add madsnorgaard/drupal-agent-resources --skill drupal-security -a codex2Manually: put the files in place
.agents/skills/drupal-security/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add madsnorgaard/drupal-agent-resources --skill drupal-security -a cursor2Manually: put the files in place
.cursor/skills/drupal-security/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install madsnorgaard/drupal-agent-resources drupal-security2Manually: put the files in place
.github/skills/drupal-security/SKILL.md1Skills CLI (Vercel)
npx skills add madsnorgaard/drupal-agent-resources --skill drupal-security -a gemini-cli2Platform CLI
gemini skills install https://github.com/madsnorgaard/drupal-agent-resources --path .claude/skills/drupal-securityManually: put the files in place
.devin/skills/drupal-security/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add madsnorgaard/drupal-agent-resources --skill drupal-security -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about drupal-security
How do I install drupal-security in Claude Code?
Run npx skills add madsnorgaard/drupal-agent-resources --skill drupal-security -a claude-code. The skill file lands at ~/.claude/skills/drupal-security/SKILL.md.
What does the drupal-security skill do?
It suggests safe Drupal patterns while code is written: parameterized queries, escaped output, permission checks and CSRF handling. It activates by itself when you touch forms, controllers, queries or user input.
Which platforms does drupal-security support?
Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode. Each has its own install command, for example gh skill install madsnorgaard/drupal-agent-resources drupal-security for GitHub Copilot.