You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
│ └─ KEEP: 20260102_WIP-viewmodel-refactoring.md (tracks ALL modules)
266
272
```
267
273
268
274
### Philosophy
@@ -291,6 +297,54 @@ Task: Home Module Refactoring
291
297
292
298
**Philosophy:** Proper imports improve readability and maintainability. Let the IDE manage imports, not inline qualifications.
293
299
300
+
### Idiomatic Kotlin
301
+
302
+
**Always use idiomatic Kotlin syntax:**
303
+
- Leverage Kotlin language features over Java-style code
304
+
- Use extension functions, data classes, sealed classes, and other Kotlin idioms
305
+
- Prefer Kotlin standard library functions (let, apply, run, also, with) when appropriate
306
+
- Use property delegation, lambda expressions, and destructuring where it improves clarity
307
+
- Follow Kotlin naming conventions and style guidelines
308
+
309
+
**Avoid static methods and utility classes:**
310
+
- ❌ WRONG: Object classes with static utility methods
311
+
- ❌ WRONG: Companion objects used as static utility holders
312
+
- ✅ RIGHT: Extension functions for utility behavior
313
+
- ✅ RIGHT: Dependency injection for shared logic
314
+
- ✅ RIGHT: Top-level functions when appropriate
315
+
316
+
**Philosophy:** Write Kotlin code that leverages the language's strengths. Avoid Java patterns that Kotlin provides better alternatives for. Make code testable and maintainable by favoring injection over static utilities.
317
+
318
+
## Code Accuracy - Verify Don't Guess
319
+
320
+
**NEVER guess parameter names, enum values, function names, or other code identifiers:**
321
+
- ❌ WRONG: Assume a parameter is named `userId` because it seems conventional
322
+
- ❌ WRONG: Guess an enum value is `ACTIVE` without checking the actual definition
323
+
- ❌ WRONG: Use `getUserById()` without verifying the actual method name
324
+
- ✅ RIGHT: Use `read_file` to check the actual class/interface definition
325
+
- ✅ RIGHT: Use `search_files` to find how the code is used elsewhere
326
+
- ✅ RIGHT: Use `list_code_definition_names` to see available methods/properties
327
+
328
+
**Before writing code that references existing types, methods, or values:**
329
+
1. **Locate the source** - Find where the type/method/enum is defined
330
+
2. **Read the definition** - Verify exact names, parameter types, and signatures
331
+
3. **Check usage examples** - See how it's used elsewhere in the codebase
332
+
4. **Use exact names** - Match capitalization, spelling, and parameter order precisely
333
+
334
+
**Common mistakes to avoid:**
335
+
- Guessing constructor parameter names without checking the data class definition
336
+
- Assuming enum values follow a pattern without verifying all cases
337
+
- Using camelCase when the project uses snake_case (or vice versa)
338
+
- Inverting boolean parameter names (e.g., `isEnabled` vs `isDisabled`)
339
+
- Getting parameter order wrong in function calls
340
+
341
+
**Tools for verification:**
342
+
- `read_file` - Read class definitions, interfaces, enums directly
343
+
- `search_files` - Find usage patterns across the codebase
344
+
- `list_code_definition_names` - Survey available methods/classes in a module
345
+
346
+
**Philosophy:** Build errors from typos and wrong names are preventable. Always verify actual code definitions before referencing them. A 30-second file check prevents a 5-minute build failure.
347
+
294
348
## File Change Handling
295
349
296
350
**When files have been modified since your last edit:**
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`userId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `selected` INTEGER NOT NULL)",
10
+
"fields": [
11
+
{
12
+
"fieldPath": "userId",
13
+
"columnName": "userId",
14
+
"affinity": "INTEGER",
15
+
"notNull": true
16
+
},
17
+
{
18
+
"fieldPath": "name",
19
+
"columnName": "name",
20
+
"affinity": "TEXT",
21
+
"notNull": true
22
+
},
23
+
{
24
+
"fieldPath": "selected",
25
+
"columnName": "selected",
26
+
"affinity": "INTEGER",
27
+
"notNull": true
28
+
}
29
+
],
30
+
"primaryKey": {
31
+
"autoGenerate": true,
32
+
"columnNames": [
33
+
"userId"
34
+
]
35
+
},
36
+
"indices": [
37
+
{
38
+
"name": "index_simple_hiit_users_userId",
39
+
"unique": false,
40
+
"columnNames": [
41
+
"userId"
42
+
],
43
+
"orders": [],
44
+
"createSql": "CREATE INDEX IF NOT EXISTS `index_simple_hiit_users_userId` ON `${TABLE_NAME}` (`userId`)"
45
+
}
46
+
]
47
+
},
48
+
{
49
+
"tableName": "simple_hiit_sessions",
50
+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `user_id` INTEGER NOT NULL, `timestamp` INTEGER NOT NULL, `duration` INTEGER NOT NULL, FOREIGN KEY(`user_id`) REFERENCES `simple_hiit_users`(`userId`) ON UPDATE NO ACTION ON DELETE CASCADE )",
51
+
"fields": [
52
+
{
53
+
"fieldPath": "sessionId",
54
+
"columnName": "session_id",
55
+
"affinity": "INTEGER",
56
+
"notNull": true
57
+
},
58
+
{
59
+
"fieldPath": "userId",
60
+
"columnName": "user_id",
61
+
"affinity": "INTEGER",
62
+
"notNull": true
63
+
},
64
+
{
65
+
"fieldPath": "timeStamp",
66
+
"columnName": "timestamp",
67
+
"affinity": "INTEGER",
68
+
"notNull": true
69
+
},
70
+
{
71
+
"fieldPath": "durationMs",
72
+
"columnName": "duration",
73
+
"affinity": "INTEGER",
74
+
"notNull": true
75
+
}
76
+
],
77
+
"primaryKey": {
78
+
"autoGenerate": true,
79
+
"columnNames": [
80
+
"session_id"
81
+
]
82
+
},
83
+
"indices": [
84
+
{
85
+
"name": "index_simple_hiit_sessions_user_id",
86
+
"unique": false,
87
+
"columnNames": [
88
+
"user_id"
89
+
],
90
+
"orders": [],
91
+
"createSql": "CREATE INDEX IF NOT EXISTS `index_simple_hiit_sessions_user_id` ON `${TABLE_NAME}` (`user_id`)"
92
+
}
93
+
],
94
+
"foreignKeys": [
95
+
{
96
+
"table": "simple_hiit_users",
97
+
"onDelete": "CASCADE",
98
+
"onUpdate": "NO ACTION",
99
+
"columns": [
100
+
"user_id"
101
+
],
102
+
"referencedColumns": [
103
+
"userId"
104
+
]
105
+
}
106
+
]
107
+
}
108
+
],
109
+
"setupQueries": [
110
+
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
111
+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6')"
0 commit comments