|
| 1 | +# Claude Code Configuration for PetSphere |
| 2 | + |
| 3 | +This directory contains tailored automation, skills, and settings for PetSphere Flutter development. |
| 4 | + |
| 5 | +## 📋 Contents |
| 6 | + |
| 7 | +### Configuration |
| 8 | +- **`settings.json`** — Project-wide settings including hooks, permissions, and MCP server configuration |
| 9 | + |
| 10 | +### Skills (User-Invocable) |
| 11 | + |
| 12 | +#### 1. `/flutter-new-component` |
| 13 | +Scaffold new reusable Flutter components following PetSphere patterns. |
| 14 | + |
| 15 | +```bash |
| 16 | +/flutter-new-component PetCard "Displays a pet profile card" |
| 17 | +/flutter-new-component HealthMetricGraph "Shows health trend chart" --stateful |
| 18 | +/flutter-new-component CareBadgeList "Lists earned care badges" --consumer |
| 19 | +``` |
| 20 | + |
| 21 | +**Output**: Creates `lib/views/components/{component_name}.dart` with proper typing, theming, and patterns. |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +#### 2. `/test-writer` |
| 26 | +Generate unit tests for Notifiers, repositories, and utilities following arrange-act-assert pattern. |
| 27 | + |
| 28 | +```bash |
| 29 | +/test-writer lib/controllers/pet_controller.dart |
| 30 | +/test-writer lib/repositories/health_repository.dart --coverage |
| 31 | +``` |
| 32 | + |
| 33 | +**Output**: Creates test files in `test/` mirroring `lib/` structure with mocks and test cases. |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +#### 3. `/migration-helper` |
| 38 | +Scaffold complete feature layers (model + repository + controller) in one command. |
| 39 | + |
| 40 | +```bash |
| 41 | +/migration-helper PetNutrition "Track pet nutrition and dietary info" --table-name=pet_nutrition |
| 42 | +/migration-helper ActivityLog "Log pet daily activities" --table-name=activity_logs |
| 43 | +``` |
| 44 | + |
| 45 | +**Output**: |
| 46 | +- `lib/models/{feature_name}_model.dart` |
| 47 | +- `lib/repositories/{feature_name}_repository.dart` |
| 48 | +- `lib/controllers/{feature_name}_controller.dart` |
| 49 | + |
| 50 | +All three files follow PetSphere architecture patterns and are production-ready. |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +### Agents (Specialized Reviewers) |
| 55 | + |
| 56 | +#### Code Reviewer (`@code-reviewer`) |
| 57 | +Comprehensive code review agent focused on Riverpod patterns, architecture compliance, and Dart best practices. |
| 58 | + |
| 59 | +```bash |
| 60 | +# Review current branch |
| 61 | +claude @code-reviewer "Review this branch for Riverpod patterns and null safety" |
| 62 | + |
| 63 | +# Review specific files |
| 64 | +claude @code-reviewer "Review lib/controllers/ for state management" |
| 65 | + |
| 66 | +# Pre-PR review |
| 67 | +claude @code-reviewer "Code review before merge" |
| 68 | +``` |
| 69 | + |
| 70 | +**Checks**: |
| 71 | +- Architecture layer compliance |
| 72 | +- Riverpod patterns (Notifier, State, providers) |
| 73 | +- Null safety and type safety |
| 74 | +- Model immutability |
| 75 | +- Repository pattern compliance |
| 76 | +- Code quality and style |
| 77 | +- Error handling |
| 78 | +- Testing readiness |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +## ⚡ Hooks (Automatic) |
| 83 | + |
| 84 | +The following hooks run automatically on file edits: |
| 85 | + |
| 86 | +### Auto-Format & Lint |
| 87 | +Runs `dart format` and `flutter analyze` after each edit. |
| 88 | +- Keeps code style consistent |
| 89 | +- Catches linting issues early |
| 90 | +- Runs automatically, no user action needed |
| 91 | + |
| 92 | +### Protected Files |
| 93 | +Prevents accidental edits to sensitive files: |
| 94 | +- `pubspec.lock` (version lock file) |
| 95 | +- `.env*` (secrets and config) |
| 96 | +- `lib/utils/supabase_config.dart` (credentials) |
| 97 | +- `android/local.properties`, `ios/local.properties` |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## 🔌 MCP Servers (Recommended) |
| 102 | + |
| 103 | +Two MCP servers are configured in `settings.json` for enhanced capabilities: |
| 104 | + |
| 105 | +### 1. **Supabase MCP** |
| 106 | +Direct access to your PostgreSQL database. |
| 107 | + |
| 108 | +**Usage**: |
| 109 | +- Inspect table schemas |
| 110 | +- Debug RLS policies |
| 111 | +- Test SQL queries |
| 112 | +- Monitor migration status |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +### 2. **context7 MCP** |
| 117 | +Real-time documentation lookup for Flutter/Dart/Riverpod. |
| 118 | + |
| 119 | +**Usage**: |
| 120 | +- Look up Flutter API docs while coding |
| 121 | +- Check Riverpod pattern documentation |
| 122 | +- Search Dart language features |
| 123 | +- Find Material Design guidelines |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +## 🚀 Quick Start |
| 128 | + |
| 129 | +### 1. Enable Hooks |
| 130 | +Hooks are configured in `settings.json` and should activate automatically. Test with: |
| 131 | +```bash |
| 132 | +# Edit any Dart file and verify `dart format` runs |
| 133 | +echo "void main(){}" > lib/test.dart |
| 134 | +# Should be auto-formatted to proper style |
| 135 | +``` |
| 136 | + |
| 137 | +### 2. Try a Skill |
| 138 | +Generate your first component: |
| 139 | +```bash |
| 140 | +/flutter-new-component TestCard "A test component" |
| 141 | +``` |
| 142 | + |
| 143 | +Look for the created file in `lib/views/components/test_card.dart`. |
| 144 | + |
| 145 | +### 3. Run a Full Feature Migration |
| 146 | +Create a complete feature layer: |
| 147 | +```bash |
| 148 | +/migration-helper TestFeature "A test feature" --table-name=test_features |
| 149 | +``` |
| 150 | + |
| 151 | +Check created files: |
| 152 | +- `lib/models/test_feature_model.dart` |
| 153 | +- `lib/repositories/test_feature_repository.dart` |
| 154 | +- `lib/controllers/test_feature_controller.dart` |
| 155 | + |
| 156 | +### 4. Code Review Before Merge |
| 157 | +Before pushing to GitHub: |
| 158 | +```bash |
| 159 | +claude @code-reviewer "Review my feature branch for architecture compliance" |
| 160 | +``` |
| 161 | + |
| 162 | +--- |
| 163 | + |
| 164 | +## 📚 Recommended Workflow |
| 165 | + |
| 166 | +### When Adding a New Feature |
| 167 | + |
| 168 | +1. **Scaffold with `/migration-helper`** |
| 169 | + ```bash |
| 170 | + /migration-helper PetNutrition "Track nutrition" --table-name=pet_nutrition |
| 171 | + ``` |
| 172 | + |
| 173 | +2. **Generate Tests with `/test-writer`** |
| 174 | + ```bash |
| 175 | + /test-writer lib/controllers/pet_nutrition_controller.dart |
| 176 | + ``` |
| 177 | + |
| 178 | +3. **Create UI Components with `/flutter-new-component`** |
| 179 | + ```bash |
| 180 | + /flutter-new-component NutritionCard "Shows nutrition info" |
| 181 | + /flutter-new-component NutritionForm "Edit nutrition record" --stateful |
| 182 | + ``` |
| 183 | + |
| 184 | +4. **Review Before Merge** |
| 185 | + ```bash |
| 186 | + claude @code-reviewer "Code review for nutrition feature" |
| 187 | + ``` |
| 188 | + |
| 189 | +5. **Hooks run automatically** — no manual linting needed |
| 190 | + |
| 191 | +--- |
| 192 | + |
| 193 | +## 🔧 Customizing |
| 194 | + |
| 195 | +### Add More Hooks |
| 196 | +Edit `settings.json` hooks section to add auto-format for other languages or add validation checks. |
| 197 | + |
| 198 | +Example: Auto-run tests on Dart file edits: |
| 199 | +```json |
| 200 | +{ |
| 201 | + "trigger": "PostToolUse", |
| 202 | + "tool": "Edit", |
| 203 | + "command": "flutter test --help" |
| 204 | +} |
| 205 | +``` |
| 206 | + |
| 207 | +### Modify Protected Files |
| 208 | +Edit the `preToolUse` section to add/remove protected paths. |
| 209 | + |
| 210 | +--- |
| 211 | + |
| 212 | +## 📖 File Organization |
| 213 | + |
| 214 | +``` |
| 215 | +.claude/ |
| 216 | +├── settings.json # Project-wide config |
| 217 | +├── README.md # This file |
| 218 | +├── skills/ |
| 219 | +│ ├── flutter-new-component/SKILL.md |
| 220 | +│ ├── test-writer/SKILL.md |
| 221 | +│ └── migration-helper/SKILL.md |
| 222 | +└── agents/ |
| 223 | + └── code-reviewer.md |
| 224 | +``` |
| 225 | + |
| 226 | +--- |
| 227 | + |
| 228 | +## 🆘 Troubleshooting |
| 229 | + |
| 230 | +### Hooks Not Running |
| 231 | +- Verify `settings.json` is valid JSON (no trailing commas) |
| 232 | +- Check file paths are correct relative to project root |
| 233 | +- Reload Claude Code: File → Reload |
| 234 | + |
| 235 | +### Skills Not Appearing |
| 236 | +- Ensure `SKILL.md` files are in `.claude/skills/{name}/SKILL.md` |
| 237 | +- Reload Claude Code |
| 238 | +- Check skill name in frontmatter matches directory name |
| 239 | + |
| 240 | +### Code Review Agent Issues |
| 241 | +- Ensure sufficient tokens available (large reviews may timeout) |
| 242 | +- Split very large PRs into multiple reviews |
| 243 | +- Check git repo is initialized (agent needs git context) |
| 244 | + |
| 245 | +--- |
| 246 | + |
| 247 | +## 📝 Notes |
| 248 | + |
| 249 | +- Skills can be customized further by editing their `.md` files |
| 250 | +- All generated code is production-ready; update with your custom logic |
| 251 | +- Tests generated have TODO comments for custom assertions |
| 252 | +- Settings are project-specific; team members should use same `.claude/` directory |
| 253 | + |
| 254 | +--- |
| 255 | + |
| 256 | +**Last Updated**: 2026-05-05 |
| 257 | +**Version**: 1.0 |
| 258 | +**Maintained by**: Claude Code Automation System |
0 commit comments