Skip to content

Commit f069f25

Browse files
committed
docs: add lessons learned from curl piping issues and versioning documentation
- Document curl piping issues and solutions from v1.0.6 - Explain versioning system and release process - Document .cursor/UPDATE.md file purpose - Add testing recommendations for piped execution - Update project organization documentation
1 parent a3d4a79 commit f069f25

File tree

1 file changed

+70
-2
lines changed

1 file changed

+70
-2
lines changed

CLAUDE.md

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ php install.php --debug --core
3838

3939
# Test installation to custom directory
4040
php install.php --all --destination=my/custom/path
41+
42+
# Test installation via curl (non-interactive)
43+
curl -s https://raw.githubusercontent.com/ivangrynenko/cursor-rules/main/install.php | php -- --ws
44+
cat install.php | php -- --core # Test piped input locally
4145
```
4246

4347
### Linting and Code Quality
@@ -47,10 +51,12 @@ php install.php --all --destination=my/custom/path
4751
## Architecture and Code Structure
4852

4953
### Project Organization
50-
- **install.php**: Main installer script (v1.0.4) - Uses builder and strategy patterns for rule set installation
54+
- **install.php**: Main installer script (current version defined by CURSOR_RULES_VERSION constant)
5155
- **.cursor/rules/**: Contains 56 MDC rule files organized by category
56+
- **.cursor/UPDATE.md**: Version history file tracking all releases and changes (created by installer)
5257
- **.tests/**: Bash test scripts for installer validation
5358
- **.github/workflows/**: CI/CD pipeline using GitHub Actions for PHP 8.3
59+
- **AGENTS.md**: Comprehensive guide for using Cursor Rules (created by installer)
5460

5561
### Rule Categories
5662
1. **Core Rules** (7 files): Git standards, testing guidelines, README maintenance
@@ -73,7 +79,69 @@ php install.php --all --destination=my/custom/path
7379
2. Script detects if running interactively or with parameters
7480
3. Creates .cursor/rules directory structure
7581
4. Downloads and installs selected rule files from GitHub
76-
5. Creates UPDATE.md file to track version
82+
5. Creates/updates .cursor/UPDATE.md file to track version history
83+
6. Creates/updates AGENTS.md documentation (unless --yes flag overwrites)
84+
85+
## Versioning System
86+
87+
### Version Management
88+
- **Version Constant**: Defined in install.php as `CURSOR_RULES_VERSION`
89+
- **Version History**: Tracked in .cursor/UPDATE.md file
90+
- **Release Process**:
91+
1. Update CURSOR_RULES_VERSION constant in install.php
92+
2. Add version entry to .cursor/UPDATE.md with date and changes
93+
3. Create GitHub release matching the version number
94+
4. Tag the release in git
95+
96+
### .cursor/UPDATE.md File Purpose
97+
The UPDATE.md file serves as a version history log that:
98+
- Tracks all changes made in each version
99+
- Documents new features, bug fixes, and improvements
100+
- Records the date of each release
101+
- Lists affected files and their impact
102+
- Notes any breaking changes
103+
- Gets created/updated automatically by the installer in user projects
104+
- Helps users understand what changed between versions
105+
106+
## Known Issues and Solutions
107+
108+
### Curl Piping Issues (Fixed in v1.0.6)
109+
When piping the installer through curl, several PHP-specific behaviors can cause problems:
110+
111+
**Problem**: Script hangs when using `curl ... | php` commands
112+
**Root Causes**:
113+
1. `$_SERVER['PHP_SELF']` becomes "Standard input code" instead of script name when piped
114+
2. PHP continues waiting for STDIN input even after script completion
115+
3. Arguments may not parse correctly when using `--` separator with piped input
116+
117+
**Solutions Implemented**:
118+
1. **Entry Point Detection**: Check for both normal execution and "Standard input code"
119+
```php
120+
if (basename(__FILE__) === basename($_SERVER['PHP_SELF'] ?? '') ||
121+
($_SERVER['PHP_SELF'] ?? '') === 'Standard input code')
122+
```
123+
124+
2. **STDIN Cleanup**: Always close STDIN before exit to prevent hanging
125+
```php
126+
if (defined('STDIN') && is_resource(STDIN)) {
127+
fclose(STDIN);
128+
}
129+
```
130+
131+
3. **Argument Parsing**: Handle both with and without `--` separator
132+
```php
133+
if (!stream_isatty(STDIN) && $_SERVER['PHP_SELF'] === 'Standard input code') {
134+
// Parse arguments from argv when piped
135+
}
136+
```
137+
138+
### Testing Coverage Gaps
139+
**Issue**: Test suite only covered direct PHP execution, not curl piping scenarios
140+
**Recommendation**: Add tests for:
141+
- `curl ... | php` execution paths
142+
- `cat install.php | php` scenarios
143+
- Argument parsing with and without `--` separator
144+
- STDIN handling in different contexts
77145

78146
## Important Considerations
79147

0 commit comments

Comments
 (0)