2.9 KiB
2.9 KiB
AGENTS.md
Author Preferences
Code Opinions
- Extract related/grouped logic (state, reactions, actions) into dedicated stores when it improves readability — keep widgets focused on rendering
- Default to writing tests: new or changed logic (stores, API clients, parsing, utils) ships with tests; when touching existing tested code, update or extend its tests. Pure UI/rendering or config changes may skip.
Infrastructure Checklist
When creating new infrastructure (screens, API clients, stores), use exploration findings as a checklist — systematically verify each convention is followed before writing code.
Never
- Never edit
.g.dartfiles directly — always regenerate withdart run build_runner build
Project
Flutter mobile app for browsing Twitch on iOS and Android. Uses MobX for state management with code generation.
Commands
flutter pub get # Install dependencies
flutter run --dart-define=CLIENT_ID=ID --dart-define=SECRET=SECRET # Run with Twitch credentials
flutter analyze # Static analysis (run after changes)
flutter test # Run tests
dart run build_runner build # Regenerate .g.dart files (MobX/JSON models)
dart run build_runner build --delete-conflicting-outputs # Same, but clears stale outputs
Source Structure
lib/apis/— API services (all extendBaseApiClient)lib/models/— Data models (@JsonSerializablewith.g.dartcodegen)lib/screens/{feature}/— Feature screens with co-locatedstores/subdirectorieslib/stores/— Global stores only (e.g.,global_assets_store.dart)lib/services/— App-level serviceslib/widgets/— Shared widgetslib/utils/— Utility functions
Architecture
- Feature stores live in
lib/screens/{feature}/stores/— don't create new top-level store files (onlylib/stores/holds global stores) - All API services extend
BaseApiClient(lib/apis/base_api_client.dart) — don't create standalone API classes - MobX stores use a generated mixin pattern — see
lib/screens/settings/stores/auth_store.dartfor the canonical example
Gotchas
- After changing MobX stores or
@JsonSerializablemodels, regenerate withdart run build_runner build. Never edit.g.dartfiles directly. Commit.g.dartfiles to source control. - The secure storage cleanup in
main.dartlooks unnecessary but handles an Android/iOS edge case where secure storage persists after uninstall. Don't remove it.
Testing
flutter testruns all tests;flutter test test/path/to/file.dartfor a single file- HTTP mocking:
http_mock_adapter(DioAdapter) — use full URLs inonGet/onPost - General mocking:
mocktail(no codegen required) - Fixtures live in
test/fixtures/(e.g.,irc_messages.dart,api_responses.dart)