|
| 1 | +--- |
| 2 | +description: How to create or update Cursor rule files for GoodData Python SDK repository |
| 3 | +alwaysApply: false |
| 4 | +--- |
| 5 | + |
| 6 | +# How to Create/Update Cursor Rule Files |
| 7 | + |
| 8 | +## Rule File Structure |
| 9 | + |
| 10 | +``` |
| 11 | +.cursor/rules/ |
| 12 | +├── cursor/ # Meta-rules about Cursor |
| 13 | +│ ├── rules.mdc # This file |
| 14 | +│ └── workflow-validation.mdc |
| 15 | +├── general/ # Always-applied core rules |
| 16 | +│ └── workflow-and-testing.mdc # ESSENTIAL: Keep concise! |
| 17 | +└── libraries/ # Library-specific rules |
| 18 | + └── gooddata-api-client.mdc |
| 19 | +``` |
| 20 | + |
| 21 | +## Rule Categories |
| 22 | + |
| 23 | +### General Rules (alwaysApply: true) |
| 24 | +Located in `general/`, always included in context. |
| 25 | + |
| 26 | +**CRITICAL**: Keep these concise - they're always loaded! |
| 27 | +- Focus on essential workflows |
| 28 | +- Use tables for quick reference |
| 29 | +- Remove redundancy |
| 30 | +- Typical size: 100-200 lines max |
| 31 | + |
| 32 | +Example: `workflow-and-testing.mdc` (merged workflow + testing essentials) |
| 33 | + |
| 34 | +### Library Rules (alwaysApply: false) |
| 35 | +Located in `libraries/`, loaded when relevant. |
| 36 | + |
| 37 | +Can be more detailed since they're conditional. |
| 38 | + |
| 39 | +Example: `gooddata-api-client.mdc` (API client regeneration) |
| 40 | + |
| 41 | +## Rule File Format |
| 42 | + |
| 43 | +```markdown |
| 44 | +--- |
| 45 | +description: Specific, keyword-rich description for Cursor's relevance detection |
| 46 | +alwaysApply: true # or false |
| 47 | +--- |
| 48 | + |
| 49 | +# Clear Title |
| 50 | + |
| 51 | +## Essential sections only |
| 52 | +``` |
| 53 | + |
| 54 | +### Writing Concise Rules |
| 55 | + |
| 56 | +**DO**: |
| 57 | +- ✅ Focus on commands and workflows |
| 58 | +- ✅ Use tables for quick reference |
| 59 | +- ✅ Include concrete examples |
| 60 | +- ✅ Keep always-applied rules under 200 lines |
| 61 | +- ✅ Merge related topics to avoid redundancy |
| 62 | + |
| 63 | +**DON'T**: |
| 64 | +- ❌ Repeat information across files |
| 65 | +- ❌ Include every possible detail |
| 66 | +- ❌ Write long explanations for obvious things |
| 67 | +- ❌ Create separate files for related topics |
| 68 | + |
| 69 | +## Description Guidelines |
| 70 | + |
| 71 | +The `description` field is critical for Cursor's relevance matching. |
| 72 | + |
| 73 | +**Good**: |
| 74 | +```yaml |
| 75 | +description: Essential development workflow and testing commands for GoodData Python SDK - formatting, linting, testing, and validation procedures |
| 76 | +``` |
| 77 | + |
| 78 | +**Bad**: |
| 79 | +```yaml |
| 80 | +description: How to work with the code |
| 81 | +``` |
| 82 | + |
| 83 | +Include keywords: package names, technologies, workflows, concepts. |
| 84 | + |
| 85 | +## Creating New Rules |
| 86 | + |
| 87 | +### When to Create |
| 88 | + |
| 89 | +- ✅ Critical workflow not covered |
| 90 | +- ✅ Library-specific patterns needed |
| 91 | +- ✅ Common mistakes to prevent |
| 92 | + |
| 93 | +### Process |
| 94 | + |
| 95 | +1. **Determine category**: General (always) or Library (conditional)? |
| 96 | +2. **Keep it concise**: Merge related topics |
| 97 | +3. **Test usefulness**: Would this solve real problems? |
| 98 | +4. **Check redundancy**: Does existing rule cover this? |
| 99 | + |
| 100 | +### Example: Adding Library Rule |
| 101 | + |
| 102 | +**User**: "Add rules for gooddata-sdk" |
| 103 | + |
| 104 | +**Action**: |
| 105 | +```bash |
| 106 | +# Create libraries/gooddata-sdk.mdc with: |
| 107 | +# - SDK-specific patterns (catalog services, data sources) |
| 108 | +# - Common imports and class structures |
| 109 | +# - Testing patterns for SDK |
| 110 | +# - Integration with API client |
| 111 | +``` |
| 112 | + |
| 113 | +Keep focused on SDK-specific knowledge, not general workflow (already in `general/`). |
| 114 | + |
| 115 | +## Repository Context |
| 116 | + |
| 117 | +### Package Structure |
| 118 | +``` |
| 119 | +gooddata-api-client/ # Generated (DO NOT EDIT) |
| 120 | +gooddata-sdk/ # Core SDK |
| 121 | +gooddata-pandas/ # Pandas integration |
| 122 | +gooddata-pipelines/ # Pipelines |
| 123 | +``` |
| 124 | + |
| 125 | +### Key Files |
| 126 | +- `Makefile` - Root commands (api-client, test, lint) |
| 127 | +- `project_common.mk` - Shared package rules |
| 128 | +- `pyproject.toml` - Ruff configuration |
| 129 | +- `.pre-commit-config.yaml` - Pre-commit hooks |
| 130 | + |
| 131 | +## Validation Checklist |
| 132 | + |
| 133 | +Before committing a rule: |
| 134 | + |
| 135 | +- [ ] Description is specific and keyword-rich |
| 136 | +- [ ] If `alwaysApply: true`, file is under 200 lines |
| 137 | +- [ ] No redundancy with other rules |
| 138 | +- [ ] Commands are accurate and tested |
| 139 | +- [ ] Examples are concrete |
| 140 | +- [ ] File is in correct directory |
| 141 | + |
| 142 | +## TODO: Future Rules |
| 143 | + |
| 144 | +Only create if truly needed: |
| 145 | +- [ ] `libraries/gooddata-sdk.mdc` - SDK patterns (if not covered by api-client rule) |
| 146 | +- [ ] `libraries/gooddata-pandas.mdc` - Pandas integration (if needed) |
| 147 | + |
| 148 | +## Related Rules |
| 149 | + |
| 150 | +- **workflow-validation.mdc** - How Cursor reports used rules |
| 151 | +- **workflow-and-testing.mdc** - Example of concise, merged general rule |
| 152 | +- **libraries/gooddata-api-client.mdc** - Example of library-specific rule |
0 commit comments