@hunghg255/maicli 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CLAUDE.md ADDED
@@ -0,0 +1,898 @@
1
+ <!-- MAICLI GUIDELINES START -->
2
+ # MAICLI Guidelines
3
+
4
+ ## Core Principles
5
+
6
+ ### 1. CLI-Only Operations
7
+ **NEVER edit .md files directly. ALL operations MUST use CLI commands.**
8
+
9
+ This ensures data integrity, maintains proper change history, and prevents file corruption.
10
+
11
+ ### 2. Documentation-First (For AI Agents)
12
+ **ALWAYS read project documentation BEFORE planning or coding.**
13
+
14
+ AI agents must understand project context, conventions, and existing patterns before making any changes. This prevents rework and ensures consistency.
15
+
16
+ ---
17
+
18
+ ## AI Agent Guidelines
19
+
20
+ > **CRITICAL**: Before performing ANY task, AI agents MUST read documentation to understand project context.
21
+
22
+ ### First-Time Initialization
23
+
24
+ When starting a new session or working on an unfamiliar project:
25
+
26
+ ```bash
27
+ # 1. List all available documentation
28
+ maicli doc list --plain
29
+
30
+ # 2. Read essential project docs (prioritize these)
31
+ maicli doc "README" --plain # Project overview
32
+ maicli doc "ARCHITECTURE" --plain # System design
33
+ maicli doc "CONVENTIONS" --plain # Coding standards
34
+ maicli doc "API" --plain # API specifications
35
+
36
+ # 3. Review current task backlog
37
+ maicli task list --plain
38
+ maicli task list --status in-progress --plain
39
+ ```
40
+
41
+ ### Before Taking Any Task
42
+
43
+ ```bash
44
+ # 1. View the task details
45
+ maicli task <id> --plain
46
+
47
+ # 2. Follow ALL refs in the task (see Reference System section)
48
+ # @.maicli/tasks/task-44 - ... → maicli task 44 --plain
49
+ # @.maicli/docs/patterns/module.md → maicli doc "patterns/module" --plain
50
+
51
+ # 3. Search for additional related documentation
52
+ maicli search "<keywords from task>" --type doc --plain
53
+
54
+ # 4. Read ALL related docs before planning
55
+ maicli doc "<related-doc>" --plain
56
+
57
+ # 5. Check for similar completed tasks (learn from history)
58
+ maicli search "<keywords>" --type task --status done --plain
59
+ ```
60
+
61
+ ### Why Documentation First?
62
+
63
+ | Without Reading Docs | With Reading Docs |
64
+ |---------------------|-------------------|
65
+ | Reinvent existing patterns | Reuse established patterns |
66
+ | Break conventions | Follow project standards |
67
+ | Duplicate code | Use existing utilities |
68
+ | Wrong architecture decisions | Align with system design |
69
+ | Inconsistent naming | Match naming conventions |
70
+
71
+ ### Context Checklist for Agents
72
+
73
+ Before writing ANY code, ensure you can answer:
74
+
75
+ - [ ] Have I followed ALL refs (`@.maicli/...`) in the task?
76
+ - [ ] Have I followed nested refs recursively?
77
+ - [ ] What is the project's overall architecture?
78
+ - [ ] What coding conventions does this project follow?
79
+ - [ ] Are there existing patterns/utilities I should reuse?
80
+ - [ ] What are the testing requirements?
81
+ - [ ] How should I structure my implementation?
82
+
83
+ > **Remember**: A few minutes reading docs saves hours of rework. NEVER skip this step.
84
+
85
+ ---
86
+
87
+ ## Reference System (Refs)
88
+
89
+ Tasks and docs can contain **references** to other tasks/docs. AI agents MUST understand and follow these refs to gather complete context.
90
+
91
+ ### Reference Formats
92
+
93
+ | Type | When Writing (Input) | When Reading (Output) | CLI Command |
94
+ |------|---------------------|----------------------|-------------|
95
+ | **Task ref** | `@task-<id>` | `@.maicli/tasks/task-<id> - <title>.md` | `maicli task <id> --plain` |
96
+ | **Doc ref** | `@doc/<path>` | `@.maicli/docs/<path>.md` | `maicli doc <path> --plain` |
97
+
98
+ > **CRITICAL for AI Agents**:
99
+ > - When **WRITING** refs (in descriptions, plans, notes): Use `@task-<id>` and `@doc/<path>`
100
+ > - When **READING** output from `--plain`: You'll see `@.maicli/tasks/...` and `@.maicli/docs/...`
101
+ > - **NEVER write** the output format (`@.maicli/...`) - always use input format (`@task-<id>`, `@doc/<path>`)
102
+
103
+ ### How to Follow Refs
104
+
105
+ When you read a task and see refs in system output format, follow them:
106
+
107
+ ```bash
108
+ # Example: Task 42 output contains:
109
+ # @.maicli/tasks/task-44 - CLI Task Create Command.md
110
+ # @.maicli/docs/patterns/module.md
111
+
112
+ # Follow task ref (extract ID from task-<id>)
113
+ maicli task 44 --plain
114
+
115
+ # Follow doc ref (extract path, remove .md)
116
+ maicli doc "patterns/module" --plain
117
+ ```
118
+
119
+ ### Parsing Rules
120
+
121
+ 1. **Task refs**: `@.maicli/tasks/task-<id> - ...` → extract `<id>` → `maicli task <id> --plain`
122
+ 2. **Doc refs**: `@.maicli/docs/<path>.md` → extract `<path>` → `maicli doc "<path>" --plain`
123
+
124
+ ### Recursive Following
125
+
126
+ Refs can be nested. Follow until complete context is gathered:
127
+
128
+ ```
129
+ Task 42
130
+ → @.maicli/docs/README.md
131
+ → @.maicli/docs/patterns/module.md (found in README)
132
+ → (read for full pattern details)
133
+ ```
134
+
135
+ ### When to Follow Refs
136
+
137
+ | Situation | Action |
138
+ |-----------|--------|
139
+ | Refs in Description | ALWAYS follow - critical context |
140
+ | Refs in Implementation Plan | Follow if implementing related work |
141
+ | Refs in Notes | Optional - for historical context |
142
+ | Dependency mentions | Follow if marked as blocker |
143
+
144
+ ### Example: Complete Ref Resolution
145
+
146
+ ```bash
147
+ # 1. Read the task
148
+ $ maicli task 42 --plain
149
+
150
+ # Output contains:
151
+ # @.maicli/tasks/task-44 - CLI Task Create Command.md
152
+ # @.maicli/docs/README.md
153
+
154
+ # 2. Follow task ref
155
+ $ maicli task 44 --plain
156
+
157
+ # 3. Follow doc ref
158
+ $ maicli doc "README" --plain
159
+
160
+ # 4. If README contains more refs, follow them too
161
+ # @.maicli/docs/patterns/module.md → maicli doc "patterns/module" --plain
162
+
163
+ # Now you have complete context
164
+ ```
165
+
166
+ > **CRITICAL**: Never assume you understand a task fully without following its refs. Refs contain essential context that may change your implementation approach.
167
+
168
+ ---
169
+
170
+ ## Quick Start
171
+
172
+ ```bash
173
+ # Initialize project
174
+ maicli init [name]
175
+
176
+ # Create task with acceptance criteria
177
+ maicli task create "Title" -d "Description" --ac "Criterion 1" --ac "Criterion 2"
178
+
179
+ # View task (ALWAYS use --plain for AI)
180
+ maicli task <id> --plain # Shorthand
181
+ maicli task view <id> --plain # Full command
182
+
183
+ # View doc (ALWAYS use --plain for AI)
184
+ maicli doc <path> --plain # Shorthand
185
+ maicli doc view "<path>" --plain # Full command
186
+
187
+ # List tasks
188
+ maicli task list --plain
189
+
190
+ # Search (tasks + docs)
191
+ maicli search "query" --plain
192
+ ```
193
+
194
+ ---
195
+
196
+ ## End-to-End Example
197
+
198
+ Here's a complete workflow for an AI agent implementing a feature:
199
+
200
+ ```bash
201
+ # === AGENT SESSION START (Do this once per session) ===
202
+
203
+ # 0a. List all available documentation
204
+ $ maicli doc list --plain
205
+
206
+ # Output:
207
+ # DOC: README.md
208
+ # DOC: ARCHITECTURE.md
209
+ # DOC: CONVENTIONS.md
210
+ # DOC: security-patterns.md
211
+ # DOC: api-guidelines.md
212
+ # DOC: email-templates.md
213
+
214
+ # 0b. Read essential project docs
215
+ $ maicli doc "README" --plain
216
+ $ maicli doc "ARCHITECTURE" --plain
217
+ $ maicli doc "CONVENTIONS" --plain
218
+
219
+ # Now the agent understands project context and conventions
220
+
221
+ # === TASK WORKFLOW ===
222
+
223
+ # 1. Create the task
224
+ $ maicli task create "Add password reset flow" \
225
+ -d "Users need ability to reset forgotten passwords via email" \
226
+ --ac "User can request password reset via email" \
227
+ --ac "Reset link expires after 1 hour" \
228
+ --ac "User can set new password via reset link" \
229
+ --ac "Unit tests cover all scenarios" \
230
+ --priority high \
231
+ -l "auth,feature"
232
+
233
+ # Output: Created task AUTH-042
234
+
235
+ # 2. Take the task and start timer (uses defaultAssignee or @me fallback)
236
+ $ maicli task edit AUTH-042 -s in-progress -a $(maicli config get defaultAssignee --plain || echo "@me")
237
+ $ maicli time start AUTH-042
238
+
239
+ # Output: Timer started for AUTH-042
240
+
241
+ # 3. Search for related documentation
242
+ $ maicli search "password security" --type doc --plain
243
+
244
+ # Output:
245
+ # DOC: security-patterns.md (score: 0.92)
246
+ # DOC: email-templates.md (score: 0.78)
247
+
248
+ # 4. Read the documentation
249
+ $ maicli doc "security-patterns" --plain
250
+
251
+ # 5. Create implementation plan (SHARE WITH USER, WAIT FOR APPROVAL)
252
+ $ maicli task edit AUTH-042 --plan $'1. Review security patterns (see @doc/security-patterns)
253
+ 2. Design token generation with 1-hour expiry
254
+ 3. Create email template (see @doc/email-templates)
255
+ 4. Implement /forgot-password endpoint
256
+ 5. Implement /reset-password endpoint
257
+ 6. Add unit tests
258
+ 7. Update API documentation'
259
+
260
+ # 6. After approval, implement and check criteria as you go
261
+ $ maicli task edit AUTH-042 --check-ac 1
262
+ $ maicli task edit AUTH-042 --append-notes "✓ Implemented /forgot-password endpoint"
263
+
264
+ $ maicli task edit AUTH-042 --check-ac 2
265
+ $ maicli task edit AUTH-042 --append-notes "✓ Token expiry set to 1 hour"
266
+
267
+ $ maicli task edit AUTH-042 --check-ac 3
268
+ $ maicli task edit AUTH-042 --append-notes "✓ Implemented /reset-password endpoint"
269
+
270
+ $ maicli task edit AUTH-042 --check-ac 4
271
+ $ maicli task edit AUTH-042 --append-notes "✓ Added 12 unit tests, 100% coverage"
272
+
273
+ # 7. Add final implementation notes
274
+ $ maicli task edit AUTH-042 --notes $'## Summary
275
+ Implemented complete password reset flow with secure token generation.
276
+
277
+ ## Changes
278
+ - Added POST /forgot-password endpoint
279
+ - Added POST /reset-password endpoint
280
+ - Created password_reset_tokens table
281
+ - Added email template for reset link
282
+
283
+ ## Security
284
+ - Tokens use crypto.randomBytes(32)
285
+ - 1-hour expiry enforced at DB level
286
+ - Rate limiting: 3 requests per hour per email
287
+
288
+ ## Tests
289
+ - 12 unit tests added
290
+ - Coverage: 100% for new code
291
+
292
+ ## Documentation
293
+ - Updated API.md with new endpoints'
294
+
295
+ # 8. Stop timer and complete
296
+ $ maicli time stop
297
+ $ maicli task edit AUTH-042 -s done
298
+
299
+ # Output: Task AUTH-042 marked as done
300
+ ```
301
+
302
+ ---
303
+
304
+ ## Task Workflow
305
+
306
+ ### Step 1: Take Task
307
+
308
+ ```bash
309
+ # Assign using defaultAssignee from config (falls back to @me if not set)
310
+ maicli task edit <id> -s in-progress -a $(maicli config get defaultAssignee --plain || echo "@me")
311
+ ```
312
+
313
+ > **Note**: The `defaultAssignee` is configured in `.maicli/config.json` during `maicli init`. If not set, `@me` is used as fallback. To update: `maicli config set defaultAssignee "@username"`
314
+
315
+ ### Step 2: Start Time Tracking (REQUIRED)
316
+
317
+ ```bash
318
+ maicli time start <id>
319
+ ```
320
+
321
+ > **CRITICAL**: Time tracking is MANDATORY. Always start timer when taking a task and stop when done. This data is essential for:
322
+ > - Accurate project estimation
323
+ > - Identifying bottlenecks
324
+ > - Resource planning
325
+ > - Sprint retrospectives
326
+
327
+ ### Step 3: Read Related Documentation
328
+
329
+ > **FOR AI AGENTS**: This step is MANDATORY, not optional. You must understand the codebase before planning.
330
+
331
+ ```bash
332
+ # Search for related docs
333
+ maicli search "authentication" --type doc --plain
334
+
335
+ # View relevant documents
336
+ maicli doc "API Guidelines" --plain
337
+ maicli doc "Security Patterns" --plain
338
+
339
+ # Also check for similar completed tasks
340
+ maicli search "auth" --type task --status done --plain
341
+ ```
342
+
343
+ > **CRITICAL**: ALWAYS read related documentation BEFORE planning! Understanding existing patterns and conventions prevents rework and ensures consistency.
344
+
345
+ ### Step 4: Create Implementation Plan
346
+
347
+ ```bash
348
+ maicli task edit <id> --plan $'1. Research patterns (see @doc/security-patterns)
349
+ 2. Design middleware
350
+ 3. Implement
351
+ 4. Add tests
352
+ 5. Update docs'
353
+ ```
354
+
355
+ > **CRITICAL**:
356
+ > - Share plan with user and **WAIT for approval** before coding
357
+ > - Include doc references using `@doc/<path>` format
358
+
359
+ ### Step 5: Implement
360
+
361
+ ```bash
362
+ # Work through implementation plan step by step
363
+ # IMPORTANT: Only check AC AFTER completing the work, not before
364
+
365
+ # After completing work for AC #1:
366
+ maicli task edit <id> --check-ac 1
367
+ maicli task edit <id> --append-notes "✓ Completed: <brief description>"
368
+
369
+ # After completing work for AC #2:
370
+ maicli task edit <id> --check-ac 2
371
+ maicli task edit <id> --append-notes "✓ Completed: <brief description>"
372
+ ```
373
+
374
+ > **CRITICAL**: Never check an AC before the work is actually done. ACs represent completed outcomes, not intentions.
375
+
376
+ ### Step 6: Handle Dynamic Requests (During Implementation)
377
+
378
+ If the user adds new requirements during implementation:
379
+
380
+ ```bash
381
+ # Add new acceptance criteria
382
+ maicli task edit <id> --ac "New requirement from user"
383
+
384
+ # Update implementation plan to include new steps
385
+ maicli task edit <id> --plan $'1. Original step 1
386
+ 2. Original step 2
387
+ 3. NEW: Handle user request for X
388
+ 4. Continue with remaining work'
389
+
390
+ # Append note about scope change
391
+ maicli task edit <id> --append-notes "⚠️ Scope updated: Added requirement for X per user request"
392
+
393
+ # Continue with Step 5 (Implement) for new requirements
394
+ ```
395
+
396
+ > **Note**: Always document scope changes. This helps track why a task took longer than expected.
397
+
398
+ ### Step 7: Add Implementation Notes
399
+
400
+ ```bash
401
+ # Add comprehensive notes (suitable for PR description)
402
+ maicli task edit <id> --notes $'## Summary
403
+
404
+ Implemented JWT auth.
405
+
406
+ ## Changes
407
+ - Added middleware
408
+ - Added tests'
409
+
410
+ # OR append progressively (recommended)
411
+ maicli task edit <id> --append-notes "✓ Implemented middleware"
412
+ maicli task edit <id> --append-notes "✓ Added tests"
413
+ ```
414
+
415
+ ### Step 8: Stop Time Tracking (REQUIRED)
416
+
417
+ ```bash
418
+ maicli time stop
419
+ ```
420
+
421
+ > **CRITICAL**: Never forget to stop the timer. If you forget, use manual entry: `maicli time add <id> <duration> -n "Forgot to stop timer"`
422
+
423
+ ### Step 9: Complete Task
424
+
425
+ ```bash
426
+ maicli task edit <id> -s done
427
+ ```
428
+
429
+ ### Step 10: Handle Post-Completion Changes (If Applicable)
430
+
431
+ If the user requests changes or updates AFTER task is marked done:
432
+
433
+ ```bash
434
+ # 1. Reopen task - set back to in-progress
435
+ maicli task edit <id> -s in-progress
436
+
437
+ # 2. Restart time tracking (REQUIRED)
438
+ maicli time start <id>
439
+
440
+ # 3. Add new AC for the changes requested
441
+ maicli task edit <id> --ac "Post-completion fix: <description>"
442
+
443
+ # 4. Document the reopen reason
444
+ maicli task edit <id> --append-notes "🔄 Reopened: User requested changes - <reason>"
445
+
446
+ # 5. Follow Step 5-9 again (Implement → Notes → Stop Timer → Done)
447
+ ```
448
+
449
+ > **CRITICAL**: Treat post-completion changes as a mini-workflow. Always:
450
+ > - Reopen task (in-progress)
451
+ > - Start timer again
452
+ > - Add AC for traceability
453
+ > - Document why it was reopened
454
+ > - Follow the same completion process
455
+
456
+ ### Step 11: Knowledge Extraction (Post-Completion)
457
+
458
+ After completing a task, extract reusable knowledge to docs:
459
+
460
+ ```bash
461
+ # Search if similar pattern already documented
462
+ maicli search "<pattern/concept>" --type doc --plain
463
+
464
+ # If new knowledge, create a doc for future reference
465
+ maicli doc create "Pattern: <Name>" \
466
+ -d "Reusable pattern discovered during task implementation" \
467
+ -t "pattern,<domain>" \
468
+ -f "patterns"
469
+
470
+ # Or append to existing doc
471
+ maicli doc edit "<existing-doc>" -a "## New Section\n\nLearned from task <id>: ..."
472
+
473
+ # Reference the source task
474
+ maicli doc edit "<doc-name>" -a "\n\n> Source: @task-<id>"
475
+ ```
476
+
477
+ **When to extract knowledge:**
478
+ - New patterns/conventions discovered
479
+ - Common error solutions
480
+ - Reusable code snippets or approaches
481
+ - Integration patterns with external services
482
+ - Performance optimization techniques
483
+
484
+ > **CRITICAL**: Only extract **generalizable** knowledge. Task-specific details belong in implementation notes, not docs.
485
+
486
+ ---
487
+
488
+ ## Essential Commands
489
+
490
+ ### Task Management
491
+
492
+ ```bash
493
+ # Create task
494
+ maicli task create "Title" -d "Description" --ac "Criterion" -l "labels" --priority high
495
+
496
+ # Edit task
497
+ maicli task edit <id> -t "New title"
498
+ maicli task edit <id> -d "New description"
499
+ maicli task edit <id> -s in-progress
500
+ maicli task edit <id> --priority high
501
+ maicli task edit <id> -a <assignee> # $(maicli config get defaultAssignee --plain || echo "@me")
502
+
503
+ # Acceptance Criteria
504
+ maicli task edit <id> --ac "New criterion" # Add
505
+ maicli task edit <id> --check-ac 1 --check-ac 2 # Check (1-indexed)
506
+ maicli task edit <id> --uncheck-ac 2 # Uncheck
507
+ maicli task edit <id> --remove-ac 3 # Remove
508
+
509
+ # Implementation Plan & Notes
510
+ maicli task edit <id> --plan $'1. Step\n2. Step'
511
+ maicli task edit <id> --notes "Implementation summary"
512
+ maicli task edit <id> --append-notes "Progress update"
513
+
514
+ # View & List
515
+ maicli task <id> --plain # Shorthand (ALWAYS use --plain)
516
+ maicli task view <id> --plain # Full command
517
+ maicli task list --plain
518
+ maicli task list --status in-progress --plain
519
+ maicli task list --assignee <assignee> --plain # $(maicli config get defaultAssignee --plain || echo "@me")
520
+ maicli task list --tree --plain # Tree hierarchy
521
+ ```
522
+
523
+ ### Time Tracking
524
+
525
+ ```bash
526
+ # Timer
527
+ maicli time start <id>
528
+ maicli time stop
529
+ maicli time pause
530
+ maicli time resume
531
+ maicli time status
532
+
533
+ # Manual entry
534
+ maicli time add <id> 2h -n "Note" -d "2025-12-25"
535
+
536
+ # Reports
537
+ maicli time report --from "2025-12-01" --to "2025-12-31"
538
+ maicli time report --by-label --csv > report.csv
539
+ ```
540
+
541
+ ### Documentation
542
+
543
+ ```bash
544
+ # List & View
545
+ maicli doc list --plain
546
+ maicli doc list --tag architecture --plain
547
+ maicli doc <path> --plain # Shorthand (ALWAYS use --plain)
548
+ maicli doc view "<path>" --plain # Full command
549
+
550
+ # Create (with optional folder)
551
+ maicli doc create "Title" -d "Description" -t "tags"
552
+ maicli doc create "Title" -d "Description" -t "tags" -f "folder/path"
553
+
554
+ # Edit metadata
555
+ maicli doc edit "Doc Name" -t "New Title" --tags "new,tags"
556
+
557
+ # Edit content
558
+ maicli doc edit "Doc Name" -c "New content" # Replace content
559
+ maicli doc edit "Doc Name" -a "Appended content" # Append to content
560
+ ```
561
+
562
+ ### Search
563
+
564
+ ```bash
565
+ # Search everything
566
+ maicli search "query" --plain
567
+
568
+ # Search specific type
569
+ maicli search "auth" --type task --plain
570
+ maicli search "patterns" --type doc --plain
571
+
572
+ # Filter
573
+ maicli search "bug" --status in-progress --priority high --plain
574
+ ```
575
+
576
+ ---
577
+
578
+ ## Task Structure
579
+
580
+ ### Title
581
+
582
+ Clear summary (WHAT needs to be done).
583
+
584
+ | Bad | Good |
585
+ |-----|------|
586
+ | Do auth stuff | Add JWT authentication |
587
+ | Fix bug | Fix login timeout on slow networks |
588
+ | Update docs | Document rate limiting in API.md |
589
+
590
+ ### Description
591
+
592
+ Explains WHY and WHAT (not HOW). **Link related docs using `@doc/<path>`**
593
+
594
+ ```markdown
595
+ We need JWT authentication because sessions don't scale for our microservices architecture.
596
+
597
+ Related docs: @doc/security-patterns, @doc/api-guidelines
598
+ ```
599
+
600
+ ### Acceptance Criteria
601
+
602
+ **Outcome-oriented**, testable criteria. NOT implementation steps.
603
+
604
+ | Bad (Implementation details) | Good (Outcomes) |
605
+ |------------------------------|-----------------|
606
+ | Add function handleLogin() in auth.ts | User can login and receive JWT token |
607
+ | Use bcrypt for hashing | Passwords are securely hashed |
608
+ | Add try-catch blocks | Errors return appropriate HTTP status codes |
609
+
610
+ ### Implementation Plan
611
+
612
+ HOW to solve. Added AFTER taking task, BEFORE coding.
613
+
614
+ ```markdown
615
+ 1. Research JWT libraries (see @doc/security-patterns)
616
+ 2. Design token structure (access + refresh tokens)
617
+ 3. Implement auth middleware
618
+ 4. Add unit tests (aim for 90%+ coverage)
619
+ 5. Update API.md with new endpoints
620
+ ```
621
+
622
+ ### Implementation Notes
623
+
624
+ Summary for PR description. Added AFTER completion.
625
+
626
+ ```markdown
627
+ ## Summary
628
+ Implemented JWT auth using jsonwebtoken library.
629
+
630
+ ## Changes
631
+ - Added auth middleware in src/middleware/auth.ts
632
+ - Added /login and /refresh endpoints
633
+ - Created JWT utility functions
634
+
635
+ ## Tests
636
+ - Added 15 unit tests
637
+ - Coverage: 94%
638
+
639
+ ## Documentation
640
+ - Updated API.md with authentication section
641
+ ```
642
+
643
+ ---
644
+
645
+ ## Error Handling
646
+
647
+ ### Common Errors and Solutions
648
+
649
+ | Error | Cause | Solution |
650
+ |-------|-------|----------|
651
+ | `Error: Task not found` | Invalid task ID | Run `maicli task list --plain` to find correct ID |
652
+ | `Error: No active timer` | Calling `time stop` without active timer | Start timer first: `maicli time start <id>` |
653
+ | `Error: Timer already running` | Starting timer when one is active | Stop current: `maicli time stop` |
654
+ | `Error: Invalid status` | Wrong status format | Use lowercase with hyphens: `in-progress`, not `In Progress` |
655
+ | `Error: AC index out of range` | Checking non-existent criterion | View task first: `maicli task <id> --plain` |
656
+ | `Error: Document not found` | Wrong document name | Run `maicli doc list --plain` to find correct name |
657
+ | `Error: Not initialized` | Running commands without init | Run `maicli init` first |
658
+
659
+ ### Debugging Commands
660
+
661
+ ```bash
662
+ # Check CLI version
663
+ maicli --version
664
+
665
+ # Verify project is initialized
666
+ maicli status
667
+
668
+ # View raw task data (for debugging)
669
+ maicli task <id> --json
670
+
671
+ # Check timer status
672
+ maicli time status
673
+ ```
674
+
675
+ ---
676
+
677
+ ## Definition of Done
678
+
679
+ A task is **Done** ONLY when **ALL** criteria are met:
680
+
681
+ ### Via CLI (Required)
682
+
683
+ - [ ] All acceptance criteria checked: `--check-ac <index>` (only after work is actually done)
684
+ - [ ] Implementation notes added: `--notes "..."`
685
+ - [ ] ⏱️ Timer stopped: `maicli time stop` (MANDATORY - do not skip!)
686
+ - [ ] Status set to done: `-s done`
687
+ - [ ] Knowledge extracted to docs (if applicable)
688
+
689
+ ### Via Code (Required)
690
+
691
+ - [ ] All tests pass
692
+ - [ ] Documentation updated
693
+ - [ ] Code reviewed (linting, formatting)
694
+ - [ ] No regressions introduced
695
+
696
+ ---
697
+
698
+ ## Status & Priority Reference
699
+
700
+ ### Status Values
701
+
702
+ Use **lowercase with hyphens**:
703
+
704
+ | Status | Description | When to Use |
705
+ |--------|-------------|-------------|
706
+ | `todo` | Not started | Default for new tasks |
707
+ | `in-progress` | Currently working | After taking task |
708
+ | `in-review` | In code review | PR submitted |
709
+ | `blocked` | Waiting on dependency | External blocker |
710
+ | `done` | Completed | All criteria met |
711
+
712
+ ### Priority Values
713
+
714
+ | Priority | Description |
715
+ |----------|-------------|
716
+ | `low` | Can wait, nice-to-have |
717
+ | `medium` | Normal priority (default) |
718
+ | `high` | Urgent, time-sensitive |
719
+
720
+ ---
721
+
722
+ ## Common Mistakes
723
+
724
+ | Wrong | Right |
725
+ |-------|-------|
726
+ | Edit .md files directly | Use `maicli task edit` |
727
+ | Change `- [ ]` to `- [x]` in file | Use `--check-ac <index>` |
728
+ | Check AC before completing work | Only check AC AFTER work is actually done |
729
+ | Skip time tracking | ALWAYS use `time start` and `time stop` |
730
+ | Start coding without reading docs | Read ALL related docs FIRST |
731
+ | Skip `maicli doc list` on new project | Always list docs when starting |
732
+ | Assume you know the conventions | Read CONVENTIONS/ARCHITECTURE docs |
733
+ | Plan without checking docs | Read docs before planning |
734
+ | Ignore similar completed tasks | Search done tasks for patterns |
735
+ | Missing doc links in description/plan | Link docs using `@doc/<path>` |
736
+ | Write refs as `@.maicli/docs/...` or `@.maicli/tasks/...` | Use input format: `@doc/<path>`, `@task-<id>` |
737
+ | Forget `--plain` flag | Always use `--plain` for AI |
738
+ | Code before plan approval | Share plan, WAIT for approval |
739
+ | Mark done without all criteria | Check ALL criteria first |
740
+ | Write implementation steps in AC | Write outcome-oriented criteria |
741
+ | Use `"In Progress"` or `"Done"` | Use `in-progress`, `done` |
742
+ | Use `@yourself` or unknown assignee | Use `$(maicli config get defaultAssignee --plain \|\| echo "@me")` |
743
+ | Ignore refs in task description | Follow ALL refs (`@.maicli/...`) before planning |
744
+ | See `@.maicli/docs/...` but don't read | Use `maicli doc "<path>" --plain` |
745
+ | See `@.maicli/tasks/task-X` but don't check | Use `maicli task X --plain` for context |
746
+ | Follow only first-level refs | Recursively follow nested refs until complete |
747
+
748
+ ---
749
+
750
+ ## Platform-Specific Notes
751
+
752
+ ### Multi-line Input
753
+
754
+ Different shells handle multi-line strings differently:
755
+
756
+ **Bash / Zsh (Recommended)**
757
+ ```bash
758
+ maicli task edit <id> --plan $'1. First step\n2. Second step\n3. Third step'
759
+ ```
760
+
761
+ **PowerShell**
762
+ ```powershell
763
+ maicli task edit <id> --plan "1. First step`n2. Second step`n3. Third step"
764
+ ```
765
+
766
+ **Cross-platform (Using printf)**
767
+ ```bash
768
+ maicli task edit <id> --plan "$(printf '1. First step\n2. Second step\n3. Third step')"
769
+ ```
770
+
771
+ **Using heredoc (for long content)**
772
+ ```bash
773
+ maicli task edit <id> --plan "$(cat <<EOF
774
+ 1. First step
775
+ 2. Second step
776
+ 3. Third step
777
+ EOF
778
+ )"
779
+ ```
780
+
781
+ ### Path Separators
782
+
783
+ - **Unix/macOS**: Use forward slashes: `./docs/api.md`
784
+ - **Windows**: Both work, but prefer forward slashes for consistency
785
+
786
+ ---
787
+
788
+ ## Best Practices Checklist
789
+
790
+ ### For AI Agents: Session Start
791
+
792
+ - [ ] List all docs: `maicli doc list --plain`
793
+ - [ ] Read README/ARCHITECTURE docs
794
+ - [ ] Understand coding conventions
795
+ - [ ] Review current task backlog
796
+
797
+ ### Before Starting Work
798
+
799
+ - [ ] Task has clear acceptance criteria
800
+ - [ ] ALL refs in task followed (`@.maicli/...`)
801
+ - [ ] Nested refs recursively followed until complete context gathered
802
+ - [ ] Related docs searched: `maicli search "keyword" --type doc --plain`
803
+ - [ ] ALL relevant docs read: `maicli doc "Doc Name" --plain`
804
+ - [ ] Similar done tasks reviewed for patterns
805
+ - [ ] Task assigned to self: `-a $(maicli config get defaultAssignee --plain || echo "@me")`
806
+ - [ ] Status set to in-progress: `-s in-progress`
807
+ - [ ] Timer started: `maicli time start <id>`
808
+
809
+ ### During Work
810
+
811
+ - [ ] Implementation plan created and approved
812
+ - [ ] Doc links included in plan: `@doc/<path>`
813
+ - [ ] Criteria checked as completed: `--check-ac <index>`
814
+ - [ ] Progress notes appended: `--append-notes "✓ ..."`
815
+
816
+ ### After Work
817
+
818
+ - [ ] All acceptance criteria checked (only after work is done)
819
+ - [ ] Implementation notes added: `--notes "..."`
820
+ - [ ] Timer stopped: `maicli time stop`
821
+ - [ ] Tests passing
822
+ - [ ] Documentation updated
823
+ - [ ] Status set to done: `-s done`
824
+ - [ ] Knowledge extracted to docs (if applicable): patterns, solutions, conventions
825
+
826
+ ---
827
+
828
+ ## Quick Reference Card
829
+
830
+ ```bash
831
+ # === AGENT INITIALIZATION (Once per session) ===
832
+ maicli doc list --plain
833
+ maicli doc "README" --plain
834
+ maicli doc "ARCHITECTURE" --plain
835
+ maicli doc "CONVENTIONS" --plain
836
+
837
+ # === FULL WORKFLOW ===
838
+ maicli task create "Title" -d "Description" --ac "Criterion"
839
+ maicli task edit <id> -s in-progress -a $(maicli config get defaultAssignee --plain || echo "@me")
840
+ maicli time start <id> # ⏱️ REQUIRED: Start timer
841
+ maicli search "keyword" --type doc --plain
842
+ maicli doc "Doc Name" --plain
843
+ maicli search "keyword" --type task --status done --plain # Learn from history
844
+ maicli task edit <id> --plan $'1. Step (see @doc/file)\n2. Step'
845
+ # ... wait for approval, then implement ...
846
+ # Only check AC AFTER completing the work:
847
+ maicli task edit <id> --check-ac 1
848
+ maicli task edit <id> --append-notes "✓ Completed: feature X"
849
+ maicli task edit <id> --check-ac 2
850
+ maicli task edit <id> --append-notes "✓ Completed: feature Y"
851
+ maicli time stop # ⏱️ REQUIRED: Stop timer
852
+ maicli task edit <id> -s done
853
+ # Optional: Extract knowledge to docs if generalizable patterns found
854
+
855
+ # === VIEW & SEARCH ===
856
+ maicli task <id> --plain # Shorthand for view
857
+ maicli task list --plain
858
+ maicli task list --status in-progress --assignee $(maicli config get defaultAssignee --plain || echo "@me") --plain
859
+ maicli search "query" --plain
860
+ maicli search "bug" --type task --status in-progress --plain
861
+
862
+ # === TIME TRACKING ===
863
+ maicli time start <id>
864
+ maicli time stop
865
+ maicli time status
866
+ maicli time report --from "2025-12-01" --to "2025-12-31"
867
+
868
+ # === DOCUMENTATION ===
869
+ maicli doc list --plain
870
+ maicli doc "path/doc-name" --plain # Shorthand for view
871
+ maicli doc create "Title" -d "Description" -t "tags" -f "folder"
872
+ maicli doc edit "doc-name" -c "New content"
873
+ maicli doc edit "doc-name" -a "Appended content"
874
+ ```
875
+
876
+ ---
877
+
878
+ **Maintained By**: MAICLI Team
879
+
880
+ <!-- MAICLI GUIDELINES END -->
881
+
882
+
883
+
884
+
885
+
886
+
887
+
888
+
889
+
890
+
891
+
892
+
893
+
894
+
895
+
896
+
897
+
898
+