This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a repository for managing and distributing Cursor AI rules, particularly focused on web development with strong emphasis on PHP/Drupal, frontend frameworks, and security best practices. The project provides an interactive PHP installer that allows developers to selectively install rule sets into their projects.
# Run all tests
cd .tests && ./run-all-tests.sh
# Run individual test scripts
cd .tests
./test-copy.sh # Test basic installation functionality
./test-debug.sh # Test debug mode
./test-invalid-option.sh # Test invalid option handling
./test-conflicting-options.sh # Test conflicting options
./test-missing-files.sh # Test missing file handling# Test installation interactively
php install.php
# Test with specific options
php install.php --core # Install core rules only
php install.php --web-stack # Install web stack rules (includes core)
php install.php --python # Install Python rules (includes core)
php install.php --all # Install all rules
# Test with debug mode
php install.php --debug --core
# Test installation to custom directory
php install.php --all --destination=my/custom/path
# Test installation via curl (non-interactive)
curl -s https://raw.githubusercontent.com/ivangrynenko/cursor-rules/main/install.php | php -- --ws
cat install.php | php -- --core # Test piped input locally- PHP syntax validation:
php -l install.php - No specific linting commands configured - consider adding phpcs/phpmd
- install.php: Main installer script (current version defined by CURSOR_RULES_VERSION constant)
- .cursor/rules/: Contains 56 MDC rule files organized by category
- .cursor/UPDATE.md: Installation receipt file tracking installed version and configuration (created by installer)
- .tests/: Bash test scripts for installer validation
- .github/workflows/: CI/CD pipeline using GitHub Actions for PHP 8.3
- AGENTS.md: Comprehensive guide for using Cursor Rules (created by installer)
- Core Rules (7 files): Git standards, testing guidelines, README maintenance
- Web Development Rules:
- Frontend: JavaScript, React, Vue, Tailwind, accessibility
- Backend: PHP/Drupal standards, database
- Security: OWASP Top 10 implementations for Drupal
- DevOps: Docker, Lagoon, Vortex configurations
- Python Rules (10 files): Security-focused rules following OWASP standards
- Installer Architecture:
- Stateless design - each execution is independent
- Builder pattern for rule set construction
- Strategy pattern for interactive vs non-interactive modes
- Factory pattern for rule set management
- User executes install.php (directly or via curl)
- Script detects if running interactively or with parameters
- Creates .cursor/rules directory structure
- Downloads and installs selected rule files from GitHub
- Creates/overwrites .cursor/UPDATE.md file as an installation receipt
- Creates/updates AGENTS.md documentation (unless --yes flag overwrites)
- Version Constant: Defined in install.php as
CURSOR_RULES_VERSION - Version History: Tracked in GitHub releases and repository documentation
- Release Process:
- Update CURSOR_RULES_VERSION constant in install.php
- Update version history in repository documentation
- Create GitHub release matching the version number
- Tag the release in git
The UPDATE.md file serves as an installation receipt that:
- Records the version of cursor-rules that was installed
- Documents the installation date and time
- Lists the number of rule files installed
- Shows the installation type (core, web-stack, Python, etc.)
- Records any tag filters that were applied
- Gets created/overwritten by the installer on each run
- Helps users identify which version and configuration they have installed
When piping the installer through curl, several PHP-specific behaviors can cause problems:
Problem: Script hangs when using curl ... | php commands
Root Causes:
$_SERVER['PHP_SELF']becomes "Standard input code" instead of script name when piped- PHP continues waiting for STDIN input even after script completion
- Arguments may not parse correctly when using
--separator with piped input
Solutions Implemented:
-
Entry Point Detection: Check for both normal execution and "Standard input code"
if (basename(__FILE__) === basename($_SERVER['PHP_SELF'] ?? '') || ($_SERVER['PHP_SELF'] ?? '') === 'Standard input code')
-
STDIN Cleanup: Always close STDIN before exit to prevent hanging
if (defined('STDIN') && is_resource(STDIN)) { fclose(STDIN); }
-
Argument Parsing: Handle both with and without
--separatorif (!stream_isatty(STDIN) && $_SERVER['PHP_SELF'] === 'Standard input code') { // Parse arguments from argv when piped }
Issue: Test suite only covered direct PHP execution, not curl piping scenarios Recommendation: Add tests for:
curl ... | phpexecution pathscat install.php | phpscenarios- Argument parsing with and without
--separator - STDIN handling in different contexts
- Follow MDC format (Markdown with custom rule syntax)
- Place in appropriate category under .cursor/rules/
- Update the rule arrays in install.php (core_rules, web_stack_rules, python_rules)
- Add rule to README.md documentation table
- Consider rule dependencies (e.g., web stack includes core rules)
- Maintain PHP 8.3+ compatibility
- Preserve both interactive and non-interactive modes
- Update CURSOR_RULES_VERSION constant when making changes
- Ensure all tests pass before committing
- Test with both local files and GitHub downloads
- All tests are bash scripts in .tests/ directory
- Tests use temporary directories to avoid affecting the actual installation
- Each test should output clear success/failure messages
- GitHub Actions runs all tests on push/PR to main branch
- Never commit sensitive information or API keys
- Rule files should not contain hardcoded credentials
- Installer validates file permissions and directory creation
- Downloaded files are fetched over HTTPS from GitHub
- Follow conventional commits format (fix:, feat:, docs:, etc.)
- Update relevant documentation when adding features
- Ensure all tests pass before submitting PR
- New rules should include clear descriptions and examples