Drupal-optimized extension for cc-sessions with quality gates, task templates, and specialized agents
Project description
cc-sessions-drupal
Drupal-optimized extension for cc-sessions that adds quality gates, specialized agents, and workflow enhancements for Drupal 10/11 development.
Features
🎯 Quality Gates
Automatic validation on task completion:
- PHPCS - Drupal coding standards enforcement (blocks completion if errors)
- Security Scan - SQL injection, XSS, access control validation
- Config Export - Configuration sync status checking
- Behat Tests - Optional functional test creation prompts
📋 Task Templates
Pre-configured structures for common Drupal work:
- Module Feature (
@drupal-m-*) - Custom module development - Theme Component (
@drupal-t-*) - Theme and frontend work - Content Architecture (
@drupal-a-*) - Content modeling - Migration (
@drupal-mig-*) - Data migration tasks - Config Management (
@drupal-c-*) - Configuration deployment
🤖 Specialized Agents
- drupal-architect - Architecture planning and content modeling with Context7 integration
- drupal-security-review - Comprehensive security audits
⚡ Slash Commands
Quick Drupal operations:
/drupal/phpcs- Run coding standards check/drupal/security- Run security validation/drupal/config-export- Export configuration/drupal/cache-clear- Clear all caches/drupal/behat- Run Behat tests
📊 State Tracking
Extended state management for Drupal-specific workflow tracking
🔒 Sensitive File Protection
Automatic blocking of Read/Grep access to sensitive files:
- Environment files (.env*)
- Drupal settings (settings*.php)
- SSH keys and certificates
- Database dumps (warning only)
Installation
Prerequisites
- cc-sessions installed and configured
- Drupal 10 or 11 project
- PHP 8.1+ with Composer
- Drush 12+
- ddev or Lando (recommended)
Quick Install
Python (Recommended):
pipx install cc-sessions-drupal
JavaScript/npm:
npx cc-sessions-drupal
From Source:
git clone https://github.com/gkastanis/cc-sessions-drupal.git
cd cc-sessions-drupal
./install.sh
Verify Installation
# Check that files were installed
ls sessions/templates/task-drupal/
ls sessions/commands/drupal/
ls sessions/protocols/drupal-quality-gate.md
# Verify configuration
cat sessions/sessions-config.json | grep -A 15 '"drupal"'
Usage
Creating Drupal Tasks
Use task naming conventions to trigger appropriate templates:
# Module development
mek: @drupal-m-user-dashboard
# Theme work
mek: @drupal-t-event-card
# Architecture
mek: @drupal-a-member-directory
# Migration
mek: @drupal-mig-legacy-content
# Configuration
mek: @drupal-c-views-export
Quality Gate Workflow
When you complete a task, quality gates run automatically:
You: "finito"
Claude:
🔍 Running Drupal quality gates...
Phase 1: Coding Standards
✅ PHPCS: 0 errors, 0 warnings
Phase 2: Security Validation
✅ No SQL injection patterns detected
✅ No XSS vulnerabilities found
✅ Access control checks implemented
Phase 3: Configuration Status
⚠️ Configuration changes detected
Run: ddev drush cex -y
Phase 4: Functional Tests
📋 Would you like to create Behat tests?
[Yes] [No]
Using Slash Commands
# Check coding standards
/drupal/phpcs
# With specific path
/drupal/phpcs web/modules/custom/my_module
# Run security scan
/drupal/security
# Export configuration
/drupal/config-export
# Clear caches
/drupal/cache-clear
# Run Behat tests
/drupal/behat
Example: Building a Custom Module
1. Create the task:
User: "mek: @drupal-m-newsletter-signup"
Claude loads the module template with:
- Module information structure
- Quality gate checklist
- Context manifest
- Work log sections
2. Start the task:
User: "start^ @drupal-m-newsletter-signup"
Claude:
- Creates git branch
drupal/newsletter-signup - Loads task context
- Enters discussion mode
3. Discuss and approve:
User: "I need a block that integrates with Mailchimp API"
Claude: [Discusses architecture, suggests Form API, dependency injection]
User: "yert"
4. Implementation: Claude implements:
- Module structure (
*.info.yml,*.module) - Form class with dependency injection
- Mailchimp integration service
- Configuration schema
- Proper docblocks
5. Quality gates:
User: "finito"
Claude automatically:
- Runs PHPCS → Validates Drupal standards
- Security scan → Checks for vulnerabilities
- Config check → Warns if export needed
- Behat prompt → Asks about tests
6. Commit and merge:
User: "commit and create PR"
Claude handles git operations and PR creation.
Sensitive File Protection
cc-sessions-drupal automatically blocks access to sensitive files to prevent accidental credential exposure:
Protected by default:
.envand.env.*filessettings.phpand variant files- SSH keys (id_rsa, id_ed25519)
- Certificates (.pem, .crt, .key)
Warning only (not blocked):
- SQL dumps (.sql, .dump)
- Backup files (.backup)
Customizing Protected Files
Edit sessions/extensions/drupal/sensitive-files.json:
{
"patterns": {
"custom_patterns": [
"my_secret_config\\.php$",
"local\\.settings\\.php$"
]
},
"allowlist": [
"sites/default/default.settings.php"
]
}
To allow a blocked file:
Add to the allowlist array.
To block additional files:
Add regex patterns to custom_patterns.
Configuration
Drupal Settings
Edit sessions/sessions-config.json:
{
"drupal": {
"version": "11",
"phpcs_path": "./vendor/bin/phpcs",
"phpcs_standard": "Drupal,DrupalPractice",
"config_export_mode": "warn",
"behat_prompt": true,
"behat_command": "ddev robo behat",
"drush_command": "ddev drush",
"quality_gates": {
"phpcs": true,
"security": true,
"config_check": true,
"behat": false
}
}
}
Configuration Options
config_export_mode:
"warn"- Notify but don't block completion (default)"block"- Prevent completion until config exported"manual"- Only export when explicitly requested
quality_gates:
phpcs: true- Blocks completion if errors existsecurity: true- Warns about vulnerabilities (doesn't block)config_check: true- Checks configuration statusbehat: false- Prompts but doesn't run automatically
behat_prompt:
true- Ask about creating tests on completionfalse- Skip test prompts
Customizing for Your Environment
Using Lando instead of ddev:
{
"drupal": {
"drush_command": "lando drush",
"behat_command": "lando behat"
}
}
Using native commands (no container):
{
"drupal": {
"drush_command": "drush",
"behat_command": "vendor/bin/behat"
}
}
Different PHPCS path:
{
"drupal": {
"phpcs_path": "/usr/local/bin/phpcs"
}
}
Integration with drupal-claude-code-sub-agent-collective
cc-sessions-drupal complements drupal-claude-code-sub-agent-collective:
Your Collective Provides:
- 14 specialized implementation agents
- Hub-and-spoke routing via orchestrator
- Deep Drupal API expertise
- Quality gate hooks
cc-sessions-drupal Adds:
- DAIC workflow enforcement (discuss before code)
- Task-based context management
- Persistent state across sessions
- Todo-based implementation boundaries
- Automatic quality gate protocols
Together They Provide:
- Structured discussion before implementation
- Specialized agents for complex Drupal work
- Automatic quality validation
- Persistent task and state tracking
- Configuration-driven workflows
Task Templates Reference
Module Feature Template
Pattern: @drupal-m-{feature-name}
Includes:
- Module metadata (name, type, location)
- Quality gates checklist
- Context manifest (files, dependencies)
- Architecture notes (Entity API, Plugin system, Services)
- Performance and security considerations
- Work log with sessions tracking
- Completion checklist
Theme Component Template
Pattern: @drupal-t-{component-name}
Includes:
- Component metadata
- Twig template structure
- SCSS/JavaScript organization
- Accessibility checklist
- Browser testing requirements
Content Architecture Template
Pattern: @drupal-a-{architecture-name}
Includes:
- Content types and fields
- Taxonomies and entity references
- View modes and form displays
- Migration from existing structure
Migration Template
Pattern: @drupal-mig-{migration-name}
Includes:
- Source analysis
- Field mapping
- Migration dependencies
- Rollback procedures
Config Management Template
Pattern: @drupal-c-{config-name}
Includes:
- Configuration items scope
- Update hooks
- Deployment procedures
- Testing requirements
Troubleshooting
PHPCS Not Found
Error: phpcs: command not found
Solution:
# Install PHP CodeSniffer
composer require --dev drupal/coder
composer require --dev dealerdirect/phpcodesniffer-composer-installer
# Update config
sessions/sessions-config.json:
"phpcs_path": "./vendor/bin/phpcs"
Drush Command Fails
Error: drush: command not found
Solution:
# For ddev
"drush_command": "ddev drush"
# For Lando
"drush_command": "lando drush"
# For native install
"drush_command": "./vendor/bin/drush"
Quality Gates Not Running
Check:
- Task follows naming pattern (
@drupal-*) - Configuration has Drupal section
- Trigger phrase matches sessions config (
"finito")
Templates Not Loading
Check:
# Verify templates exist
ls sessions/templates/task-drupal/
# Reinstall if missing
pipx reinstall cc-sessions-drupal
# or
npx cc-sessions-drupal
Sensitive File Blocked (But You Need Access)
Error: 🔒 Access Blocked: Sensitive File
Solution:
Add file to allowlist in sessions/extensions/drupal/sensitive-files.json:
{
"allowlist": [
"path/to/your/file.php"
]
}
Or disable the hook by removing:
rm sessions/hooks/drupal-sensitive-files.js
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
See CONTRIBUTING.md for details.
License
MIT License - see LICENSE file for details.
Credits
Built to extend:
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Drupal-Optimized | Quality Gates | DAIC Workflow | cc-sessions Extension
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cc_sessions_drupal-0.1.1.tar.gz.
File metadata
- Download URL: cc_sessions_drupal-0.1.1.tar.gz
- Upload date:
- Size: 50.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d61ee2948e1e8de9e9bf226a3054610d251aa44a64ed2cbcbd62dc276f12f3c
|
|
| MD5 |
ed310f5db4e0b596678f7cdf6d4f7317
|
|
| BLAKE2b-256 |
1040821a6d42e887e12d729f7ffcdaa09a1d148bbfac928d1eeb300f050c68c8
|
File details
Details for the file cc_sessions_drupal-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cc_sessions_drupal-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cb15e211dbc2d8d432226d4cffcf6565d7f27c081c70507e1e1644831a72037
|
|
| MD5 |
d958f92c4ef51405849586cf060215c9
|
|
| BLAKE2b-256 |
cd59c6fce469e4f0e7bd7bcac1cee14324110160cf71d1cc60240170394e96ad
|