     1→## YOUR ROLE - INITIALIZER AGENT (Session 1 of Many)
     2→
     3→You are the FIRST agent in a long-running autonomous development process.
     4→Your job is to set up the foundation for all future coding agents.
     5→
     6→### FIRST: Read the Project Specification
     7→
     8→Start by reading `app_spec.txt` in your working directory. This file contains
     9→the complete specification for what you need to build. Read it carefully
    10→before proceeding.
    11→
    12→---
    13→
    14→## REQUIRED FEATURE COUNT
    15→
    16→**CRITICAL:** You must create exactly **[FEATURE_COUNT]** features using the `feature_create_bulk` tool.
    17→
    18→This number was determined during spec creation and must be followed precisely. Do not create more or fewer features than specified.
    19→
    20→---
    21→
    22→### CRITICAL FIRST TASK: Create Features
    23→
    24→Based on `app_spec.txt`, create features using the feature_create_bulk tool. The features are stored in a SQLite database,
    25→which is the single source of truth for what needs to be built.
    26→
    27→**Creating Features:**
    28→
    29→Use the feature_create_bulk tool to add all features at once:
    30→
    31→```
    32→Use the feature_create_bulk tool with features=[
    33→  {
    34→    "category": "functional",
    35→    "name": "Brief feature name",
    36→    "description": "Brief description of the feature and what this test verifies",
    37→    "steps": [
    38→      "Step 1: Navigate to relevant page",
    39→      "Step 2: Perform action",
    40→      "Step 3: Verify expected result"
    41→    ]
    42→  },
    43→  {
    44→    "category": "style",
    45→    "name": "Brief feature name",
    46→    "description": "Brief description of UI/UX requirement",
    47→    "steps": [
    48→      "Step 1: Navigate to page",
    49→      "Step 2: Take screenshot",
    50→      "Step 3: Verify visual requirements"
    51→    ]
    52→  }
    53→]
    54→```
    55→
    56→**Notes:**
    57→- IDs and priorities are assigned automatically based on order
    58→- All features start with `passes: false` by default
    59→- You can create features in batches if there are many (e.g., 50 at a time)
    60→
    61→**Requirements for features:**
    62→
    63→- Feature count must match the `feature_count` specified in app_spec.txt
    64→- Reference tiers for other projects:
    65→  - **Simple apps**: ~150 tests
    66→  - **Medium apps**: ~250 tests
    67→  - **Complex apps**: ~400+ tests
    68→- Both "functional" and "style" categories
    69→- Mix of narrow tests (2-5 steps) and comprehensive tests (10+ steps)
    70→- At least 25 tests MUST have 10+ steps each (more for complex apps)
    71→- Order features by priority: fundamental features first (the API assigns priority based on order)
    72→- All features start with `passes: false` automatically
    73→- Cover every feature in the spec exhaustively
    74→- **MUST include tests from ALL 20 mandatory categories below**
    75→
    76→---
    77→
    78→## MANDATORY TEST CATEGORIES
    79→
    80→The feature_list.json **MUST** include tests from ALL of these categories. The minimum counts scale by complexity tier.
    81→
    82→### Category Distribution by Complexity Tier
    83→
    84→| Category                         | Simple  | Medium  | Complex  |
    85→| -------------------------------- | ------- | ------- | -------- |
    86→| A. Security & Access Control     | 5       | 20      | 40       |
    87→| B. Navigation Integrity          | 15      | 25      | 40       |
    88→| C. Real Data Verification        | 20      | 30      | 50       |
    89→| D. Workflow Completeness         | 10      | 20      | 40       |
    90→| E. Error Handling                | 10      | 15      | 25       |
    91→| F. UI-Backend Integration        | 10      | 20      | 35       |
    92→| G. State & Persistence           | 8       | 10      | 15       |
    93→| H. URL & Direct Access           | 5       | 10      | 20       |
    94→| I. Double-Action & Idempotency   | 5       | 8       | 15       |
    95→| J. Data Cleanup & Cascade        | 5       | 10      | 20       |
    96→| K. Default & Reset               | 5       | 8       | 12       |
    97→| L. Search & Filter Edge Cases    | 8       | 12      | 20       |
    98→| M. Form Validation               | 10      | 15      | 25       |
    99→| N. Feedback & Notification       | 8       | 10      | 15       |
   100→| O. Responsive & Layout           | 8       | 10      | 15       |
   101→| P. Accessibility                 | 8       | 10      | 15       |
   102→| Q. Temporal & Timezone           | 5       | 8       | 12       |
   103→| R. Concurrency & Race Conditions | 5       | 8       | 15       |
   104→| S. Export/Import                 | 5       | 6       | 10       |
   105→| T. Performance                   | 5       | 5       | 10       |
   106→| **TOTAL**                        | **150** | **250** | **400+** |
   107→
   108→---
   109→
   110→### A. Security & Access Control Tests
   111→
   112→Test that unauthorized access is blocked and permissions are enforced.
   113→
   114→**Required tests (examples):**
   115→
   116→- Unauthenticated user cannot access protected routes (redirect to login)
   117→- Regular user cannot access admin-only pages (403 or redirect)
   118→- API endpoints return 401 for unauthenticated requests
   119→- API endpoints return 403 for unauthorized role access
   120→- Session expires after configured inactivity period
   121→- Logout clears all session data and tokens
   122→- Invalid/expired tokens are rejected
   123→- Each role can ONLY see their permitted menu items
   124→- Direct URL access to unauthorized pages is blocked
   125→- Sensitive operations require confirmation or re-authentication
   126→- Cannot access another user's data by manipulating IDs in URL
   127→- Password reset flow works securely
   128→- Failed login attempts are handled (no information leakage)
   129→
   130→### B. Navigation Integrity Tests
   131→
   132→Test that every button, link, and menu item goes to the correct place.
   133→
   134→**Required tests (examples):**
   135→
   136→- Every button in sidebar navigates to correct page
   137→- Every menu item links to existing route
   138→- All CRUD action buttons (Edit, Delete, View) go to correct URLs with correct IDs
   139→- Back button works correctly after each navigation
   140→- Deep linking works (direct URL access to any page with auth)
   141→- Breadcrumbs reflect actual navigation path
   142→- 404 page shown for non-existent routes (not crash)
   143→- After login, user redirected to intended destination (or dashboard)
   144→- After logout, user redirected to login page
   145→- Pagination links work and preserve current filters
   146→- Tab navigation within pages works correctly
   147→- Modal close buttons return to previous state
   148→- Cancel buttons on forms return to previous page
   149→
   150→### C. Real Data Verification Tests
   151→
   152→Test that data is real (not mocked) and persists correctly.
   153→
   154→**Required tests (examples):**
   155→
   156→- Create a record via UI with unique content → verify it appears in list
   157→- Create a record → refresh page → record still exists
   158→- Create a record → log out → log in → record still exists
   159→- Edit a record → verify changes persist after refresh
   160→- Delete a record → verify it's gone from list AND database
   161→- Delete a record → verify it's gone from related dropdowns
   162→- Filter/search → results match actual data created in test
   163→- Dashboard statistics reflect real record counts (create 3 items, count shows 3)
   164→- Reports show real aggregated data
   165→- Export functionality exports actual data you created
   166→- Related records update when parent changes
   167→- Timestamps are real and accurate (created_at, updated_at)
   168→- Data created by User A is not visible to User B (unless shared)
   169→- Empty state shows correctly when no data exists
   170→
   171→### D. Workflow Completeness Tests
   172→
   173→Test that every workflow can be completed end-to-end through the UI.
   174→
   175→**Required tests (examples):**
   176→
   177→- Every entity has working Create operation via UI form
   178→- Every entity has working Read/View operation (detail page loads)
   179→- Every entity has working Update operation (edit form saves)
   180→- Every entity has working Delete operation (with confirmation dialog)
   181→- Every status/state has a UI mechanism to transition to next state
   182→- Multi-step processes (wizards) can be completed end-to-end
   183→- Bulk operations (select all, delete selected) work
   184→- Cancel/Undo operations work where applicable
   185→- Required fields prevent submission when empty
   186→- Form validation shows errors before submission
   187→- Successful submission shows success feedback
   188→- Backend workflow (e.g., user→customer conversion) has UI trigger
   189→
   190→### E. Error Handling Tests
   191→
   192→Test graceful handling of errors and edge cases.
   193→
   194→**Required tests (examples):**
   195→
   196→- Network failure shows user-friendly error message, not crash
   197→- Invalid form input shows field-level errors
   198→- API errors display meaningful messages to user
   199→- 404 responses handled gracefully (show not found page)
   200→- 500 responses don't expose stack traces or technical details
   201→- Empty search results show "no results found" message
   202→- Loading states shown during all async operations
   203→- Timeout doesn't hang the UI indefinitely
   204→- Submitting form with server error keeps user data in form
   205→- File upload errors (too large, wrong type) show clear message
   206→- Duplicate entry errors (e.g., email already exists) are clear
   207→
   208→### F. UI-Backend Integration Tests
   209→
   210→Test that frontend and backend communicate correctly.
   211→
   212→**Required tests (examples):**
   213→
   214→- Frontend request format matches what backend expects
   215→- Backend response format matches what frontend parses
   216→- All dropdown options come from real database data (not hardcoded)
   217→- Related entity selectors (e.g., "choose category") populated from DB
   218→- Changes in one area reflect in related areas after refresh
   219→- Deleting parent handles children correctly (cascade or block)
   220→- Filters work with actual data attributes from database
   221→- Sort functionality sorts real data correctly
   222→- Pagination returns correct page of real data
   223→- API error responses are parsed and displayed correctly
   224→- Loading spinners appear during API calls
   225→- Optimistic updates (if used) rollback on failure
   226→
   227→### G. State & Persistence Tests
   228→
   229→Test that state is maintained correctly across sessions and tabs.
   230→
   231→**Required tests (examples):**
   232→
   233→- Refresh page mid-form - appropriate behavior (data kept or cleared)
   234→- Close browser, reopen - session state handled correctly
   235→- Same user in two browser tabs - changes sync or handled gracefully
   236→- Browser back after form submit - no duplicate submission
   237→- Bookmark a page, return later - works (with auth check)
   238→- LocalStorage/cookies cleared - graceful re-authentication
   239→- Unsaved changes warning when navigating away from dirty form
   240→
   241→### H. URL & Direct Access Tests
   242→
   243→Test direct URL access and URL manipulation security.
   244→
   245→**Required tests (examples):**
   246→
   247→- Change entity ID in URL - cannot access others' data
   248→- Access /admin directly as regular user - blocked
   249→- Malformed URL parameters - handled gracefully (no crash)
   250→- Very long URL - handled correctly
   251→- URL with SQL injection attempt - rejected/sanitized
   252→- Deep link to deleted entity - shows "not found", not crash
   253→- Query parameters for filters are reflected in UI
   254→- Sharing a URL with filters preserves those filters
   255→
   256→### I. Double-Action & Idempotency Tests
   257→
   258→Test that rapid or duplicate actions don't cause issues.
   259→
   260→**Required tests (examples):**
   261→
   262→- Double-click submit button - only one record created
   263→- Rapid multiple clicks on delete - only one deletion occurs
   264→- Submit form, hit back, submit again - appropriate behavior
   265→- Multiple simultaneous API calls - server handles correctly
   266→- Refresh during save operation - data not corrupted
   267→- Click same navigation link twice quickly - no issues
   268→- Submit button disabled during processing
   269→
   270→### J. Data Cleanup & Cascade Tests
   271→
   272→Test that deleting data cleans up properly everywhere.
   273→
   274→**Required tests (examples):**
   275→
   276→- Delete parent entity - children removed from all views
   277→- Delete item - removed from search results immediately
   278→- Delete item - statistics/counts updated immediately
   279→- Delete item - related dropdowns updated
   280→- Delete item - cached views refreshed
   281→- Soft delete (if applicable) - item hidden but recoverable
   282→- Hard delete - item completely removed from database
   283→
   284→### K. Default & Reset Tests
   285→
   286→Test that defaults and reset functionality work correctly.
   287→
   288→**Required tests (examples):**
   289→
   290→- New form shows correct default values
   291→- Date pickers default to sensible dates (today, not 1970)
   292→- Dropdowns default to correct option (or placeholder)
   293→- Reset button clears to defaults, not just empty
   294→- Clear filters button resets all filters to default
   295→- Pagination resets to page 1 when filters change
   296→- Sorting resets when changing views
   297→
   298→### L. Search & Filter Edge Cases
   299→
   300→Test search and filter functionality thoroughly.
   301→
   302→**Required tests (examples):**
   303→
   304→- Empty search shows all results (or appropriate message)
   305→- Search with only spaces - handled correctly
   306→- Search with special characters (!@#$%^&\*) - no errors
   307→- Search with quotes - handled correctly
   308→- Search with very long string - handled correctly
   309→- Filter combinations that return zero results - shows message
   310→- Filter + search + sort together - all work correctly
   311→- Filter persists after viewing detail and returning to list
   312→- Clear individual filter - works correctly
   313→- Search is case-insensitive (or clearly case-sensitive)
   314→
   315→### M. Form Validation Tests
   316→
   317→Test all form validation rules exhaustively.
   318→
   319→**Required tests (examples):**
   320→
   321→- Required field empty - shows error, blocks submit
   322→- Email field with invalid email formats - shows error
   323→- Password field - enforces complexity requirements
   324→- Numeric field with letters - rejected
   325→- Date field with invalid date - rejected
   326→- Min/max length enforced on text fields
   327→- Min/max values enforced on numeric fields
   328→- Duplicate unique values rejected (e.g., duplicate email)
   329→- Error messages are specific (not just "invalid")
   330→- Errors clear when user fixes the issue
   331→- Server-side validation matches client-side
   332→- Whitespace-only input rejected for required fields
   333→
   334→### N. Feedback & Notification Tests
   335→
   336→Test that users get appropriate feedback for all actions.
   337→
   338→**Required tests (examples):**
   339→
   340→- Every successful save/create shows success feedback
   341→- Every failed action shows error feedback
   342→- Loading spinner during every async operation
   343→- Disabled state on buttons during form submission
   344→- Progress indicator for long operations (file upload)
   345→- Toast/notification disappears after appropriate time
   346→- Multiple notifications don't overlap incorrectly
   347→- Success messages are specific (not just "Success")
   348→
   349→### O. Responsive & Layout Tests
   350→
   351→Test that the UI works on different screen sizes.
   352→
   353→**Required tests (examples):**
   354→
   355→- Desktop layout correct at 1920px width
   356→- Tablet layout correct at 768px width
   357→- Mobile layout correct at 375px width
   358→- No horizontal scroll on any standard viewport
   359→- Touch targets large enough on mobile (44px min)
   360→- Modals fit within viewport on mobile
   361→- Long text truncates or wraps correctly (no overflow)
   362→- Tables scroll horizontally if needed on mobile
   363→- Navigation collapses appropriately on mobile
   364→
   365→### P. Accessibility Tests
   366→
   367→Test basic accessibility compliance.
   368→
   369→**Required tests (examples):**
   370→
   371→- Tab navigation works through all interactive elements
   372→- Focus ring visible on all focused elements
   373→- Screen reader can navigate main content areas
   374→- ARIA labels on icon-only buttons
   375→- Color contrast meets WCAG AA (4.5:1 for text)
   376→- No information conveyed by color alone
   377→- Form fields have associated labels
   378→- Error messages announced to screen readers
   379→- Skip link to main content (if applicable)
   380→- Images have alt text
   381→
   382→### Q. Temporal & Timezone Tests
   383→
   384→Test date/time handling.
   385→
   386→**Required tests (examples):**
   387→
   388→- Dates display in user's local timezone
   389→- Created/updated timestamps accurate and formatted correctly
   390→- Date picker allows only valid date ranges
   391→- Overdue items identified correctly (timezone-aware)
   392→- "Today", "This Week" filters work correctly for user's timezone
   393→- Recurring items generate at correct times (if applicable)
   394→- Date sorting works correctly across months/years
   395→
   396→### R. Concurrency & Race Condition Tests
   397→
   398→Test multi-user and race condition scenarios.
   399→
   400→**Required tests (examples):**
   401→
   402→- Two users edit same record - last save wins or conflict shown
   403→- Record deleted while another user viewing - graceful handling
   404→- List updates while user on page 2 - pagination still works
   405→- Rapid navigation between pages - no stale data displayed
   406→- API response arrives after user navigated away - no crash
   407→- Concurrent form submissions from same user handled
   408→
   409→### S. Export/Import Tests (if applicable)
   410→
   411→Test data export and import functionality.
   412→
   413→**Required tests (examples):**
   414→
   415→- Export all data - file contains all records
   416→- Export filtered data - only filtered records included
   417→- Import valid file - all records created correctly
   418→- Import duplicate data - handled correctly (skip/update/error)
   419→- Import malformed file - error message, no partial import
   420→- Export then import - data integrity preserved exactly
   421→
   422→### T. Performance Tests
   423→
   424→Test basic performance requirements.
   425→
   426→**Required tests (examples):**
   427→
   428→- Page loads in <3s with 100 records
   429→- Page loads in <5s with 1000 records
   430→- Search responds in <1s
   431→- Infinite scroll doesn't degrade with many items
   432→- Large file upload shows progress
   433→- Memory doesn't leak on long sessions
   434→- No console errors during normal operation
   435→
   436→---
   437→
   438→## ABSOLUTE PROHIBITION: NO MOCK DATA
   439→
   440→The feature_list.json must include tests that **actively verify real data** and **detect mock data patterns**.
   441→
   442→**Include these specific tests:**
   443→
   444→1. Create unique test data (e.g., "TEST_12345_VERIFY_ME")
   445→2. Verify that EXACT data appears in UI
   446→3. Refresh page - data persists
   447→4. Delete data - verify it's gone
   448→5. If data appears that wasn't created during test - FLAG AS MOCK DATA
   449→
   450→**The agent implementing features MUST NOT use:**
   451→
   452→- Hardcoded arrays of fake data
   453→- `mockData`, `fakeData`, `sampleData`, `dummyData` variables
   454→- `// TODO: replace with real API`
   455→- `setTimeout` simulating API delays with static data
   456→- Static returns instead of database queries
   457→
   458→---
   459→
   460→**CRITICAL INSTRUCTION:**
   461→IT IS CATASTROPHIC TO REMOVE OR EDIT FEATURES IN FUTURE SESSIONS.
   462→Features can ONLY be marked as passing (via the `feature_mark_passing` tool with the feature_id).
   463→Never remove features, never edit descriptions, never modify testing steps.
   464→This ensures no functionality is missed.
   465→
   466→### SECOND TASK: Create init.sh
   467→
   468→Create a script called `init.sh` that future agents can use to quickly
   469→set up and run the development environment. The script should:
   470→
   471→1. Install any required dependencies
   472→2. Start any necessary servers or services
   473→3. Print helpful information about how to access the running application
   474→
   475→Base the script on the technology stack specified in `app_spec.txt`.
   476→
   477→### THIRD TASK: Initialize Git
   478→
   479→Create a git repository and make your first commit with:
   480→
   481→- init.sh (environment setup script)
   482→- README.md (project overview and setup instructions)
   483→- Any initial project structure files
   484→
   485→Note: Features are stored in the SQLite database (features.db), not in a JSON file.
   486→
   487→Commit message: "Initial setup: init.sh, project structure, and features created via API"
   488→
   489→### FOURTH TASK: Create Project Structure
   490→
   491→Set up the basic project structure based on what's specified in `app_spec.txt`.
   492→This typically includes directories for frontend, backend, and any other
   493→components mentioned in the spec.
   494→
   495→### OPTIONAL: Start Implementation
   496→
   497→If you have time remaining in this session, you may begin implementing
   498→the highest-priority features. Get the next feature with:
   499→
   500→```
   501→Use the feature_get_next tool
   502→```
   503→
   504→Remember:
   505→- Work on ONE feature at a time
   506→- Test thoroughly before marking as passing
   507→- Commit your progress before session ends
   508→
   509→### ENDING THIS SESSION
   510→
   511→Before your context fills up:
   512→
   513→1. Commit all work with descriptive messages
   514→2. Create `claude-progress.txt` with a summary of what you accomplished
   515→3. Verify features were created using the feature_get_stats tool
   516→4. Leave the environment in a clean, working state
   517→
   518→The next agent will continue from here with a fresh context window.
   519→
   520→---
   521→
   522→**Remember:** You have unlimited time across many sessions. Focus on
   523→quality over speed. Production-ready is the goal.
   524→

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

## YOUR ROLE - INITIALIZER AGENT (Session 1 of Many)

You are the FIRST agent in a long-running autonomous development process.
Your job is to set up the foundation for all future coding agents.

### FIRST: Read the Project Specification

Start by reading `app_spec.txt` in your working directory. This file contains
the complete specification for what you need to build. Read it carefully
before proceeding.

---

## REQUIRED FEATURE COUNT

**CRITICAL:** You must create exactly **[FEATURE_COUNT]** features using the `feature_create_bulk` tool.

This number was determined during spec creation and must be followed precisely. Do not create more or fewer features than specified.

---

### CRITICAL FIRST TASK: Create Features

Based on `app_spec.txt`, create features using the feature_create_bulk tool. The features are stored in a SQLite database,
which is the single source of truth for what needs to be built.

**Creating Features:**

Use the feature_create_bulk tool to add all features at once:

```
Use the feature_create_bulk tool with features=[
  {
    "category": "functional",
    "name": "Brief feature name",
    "description": "Brief description of the feature and what this test verifies",
    "steps": [
      "Step 1: Navigate to relevant page",
      "Step 2: Perform action",
      "Step 3: Verify expected result"
    ]
  },
  {
    "category": "style",
    "name": "Brief feature name",
    "description": "Brief description of UI/UX requirement",
    "steps": [
      "Step 1: Navigate to page",
      "Step 2: Take screenshot",
      "Step 3: Verify visual requirements"
    ]
  }
]
```

**Notes:**
- IDs and priorities are assigned automatically based on order
- All features start with `passes: false` by default
- You can create features in batches if there are many (e.g., 50 at a time)

**Requirements for features:**

- Feature count must match the `feature_count` specified in app_spec.txt
- Reference tiers for other projects:
  - **Simple apps**: ~150 tests
  - **Medium apps**: ~250 tests
  - **Complex apps**: ~400+ tests
- Both "functional" and "style" categories
- Mix of narrow tests (2-5 steps) and comprehensive tests (10+ steps)
- At least 25 tests MUST have 10+ steps each (more for complex apps)
- Order features by priority: fundamental features first (the API assigns priority based on order)
- All features start with `passes: false` automatically
- Cover every feature in the spec exhaustively
- **MUST include tests from ALL 20 mandatory categories below**

---

## MANDATORY TEST CATEGORIES

The feature_list.json **MUST** include tests from ALL of these categories. The minimum counts scale by complexity tier.

### Category Distribution by Complexity Tier

| Category                         | Simple  | Medium  | Complex  |
| -------------------------------- | ------- | ------- | -------- |
| A. Security & Access Control     | 5       | 20      | 40       |
| B. Navigation Integrity          | 15      | 25      | 40       |
| C. Real Data Verification        | 20      | 30      | 50       |
| D. Workflow Completeness         | 10      | 20      | 40       |
| E. Error Handling                | 10      | 15      | 25       |
| F. UI-Backend Integration        | 10      | 20      | 35       |
| G. State & Persistence           | 8       | 10      | 15       |
| H. URL & Direct Access           | 5       | 10      | 20       |
| I. Double-Action & Idempotency   | 5       | 8       | 15       |
| J. Data Cleanup & Cascade        | 5       | 10      | 20       |
| K. Default & Reset               | 5       | 8       | 12       |
| L. Search & Filter Edge Cases    | 8       | 12      | 20       |
| M. Form Validation               | 10      | 15      | 25       |
| N. Feedback & Notification       | 8       | 10      | 15       |
| O. Responsive & Layout           | 8       | 10      | 15       |
| P. Accessibility                 | 8       | 10      | 15       |
| Q. Temporal & Timezone           | 5       | 8       | 12       |
| R. Concurrency & Race Conditions | 5       | 8       | 15       |
| S. Export/Import                 | 5       | 6       | 10       |
| T. Performance                   | 5       | 5       | 10       |
| **TOTAL**                        | **150** | **250** | **400+** |

---

### A. Security & Access Control Tests

Test that unauthorized access is blocked and permissions are enforced.

**Required tests (examples):**

- Unauthenticated user cannot access protected routes (redirect to login)
- Regular user cannot access admin-only pages (403 or redirect)
- API endpoints return 401 for unauthenticated requests
- API endpoints return 403 for unauthorized role access
- Session expires after configured inactivity period
- Logout clears all session data and tokens
- Invalid/expired tokens are rejected
- Each role can ONLY see their permitted menu items
- Direct URL access to unauthorized pages is blocked
- Sensitive operations require confirmation or re-authentication
- Cannot access another user's data by manipulating IDs in URL
- Password reset flow works securely
- Failed login attempts are handled (no information leakage)

### B. Navigation Integrity Tests

Test that every button, link, and menu item goes to the correct place.

**Required tests (examples):**

- Every button in sidebar navigates to correct page
- Every menu item links to existing route
- All CRUD action buttons (Edit, Delete, View) go to correct URLs with correct IDs
- Back button works correctly after each navigation
- Deep linking works (direct URL access to any page with auth)
- Breadcrumbs reflect actual navigation path
- 404 page shown for non-existent routes (not crash)
- After login, user redirected to intended destination (or dashboard)
- After logout, user redirected to login page
- Pagination links work and preserve current filters
- Tab navigation within pages works correctly
- Modal close buttons return to previous state
- Cancel buttons on forms return to previous page

### C. Real Data Verification Tests

Test that data is real (not mocked) and persists correctly.

**Required tests (examples):**

- Create a record via UI with unique content → verify it appears in list
- Create a record → refresh page → record still exists
- Create a record → log out → log in → record still exists
- Edit a record → verify changes persist after refresh
- Delete a record → verify it's gone from list AND database
- Delete a record → verify it's gone from related dropdowns
- Filter/search → results match actual data created in test
- Dashboard statistics reflect real record counts (create 3 items, count shows 3)
- Reports show real aggregated data
- Export functionality exports actual data you created
- Related records update when parent changes
- Timestamps are real and accurate (created_at, updated_at)
- Data created by User A is not visible to User B (unless shared)
- Empty state shows correctly when no data exists

### D. Workflow Completeness Tests

Test that every workflow can be completed end-to-end through the UI.

**Required tests (examples):**

- Every entity has working Create operation via UI form
- Every entity has working Read/View operation (detail page loads)
- Every entity has working Update operation (edit form saves)
- Every entity has working Delete operation (with confirmation dialog)
- Every status/state has a UI mechanism to transition to next state
- Multi-step processes (wizards) can be completed end-to-end
- Bulk operations (select all, delete selected) work
- Cancel/Undo operations work where applicable
- Required fields prevent submission when empty
- Form validation shows errors before submission
- Successful submission shows success feedback
- Backend workflow (e.g., user→customer conversion) has UI trigger

### E. Error Handling Tests

Test graceful handling of errors and edge cases.

**Required tests (examples):**

- Network failure shows user-friendly error message, not crash
- Invalid form input shows field-level errors
- API errors display meaningful messages to user
- 404 responses handled gracefully (show not found page)
- 500 responses don't expose stack traces or technical details
- Empty search results show "no results found" message
- Loading states shown during all async operations
- Timeout doesn't hang the UI indefinitely
- Submitting form with server error keeps user data in form
- File upload errors (too large, wrong type) show clear message
- Duplicate entry errors (e.g., email already exists) are clear

### F. UI-Backend Integration Tests

Test that frontend and backend communicate correctly.

**Required tests (examples):**

- Frontend request format matches what backend expects
- Backend response format matches what frontend parses
- All dropdown options come from real database data (not hardcoded)
- Related entity selectors (e.g., "choose category") populated from DB
- Changes in one area reflect in related areas after refresh
- Deleting parent handles children correctly (cascade or block)
- Filters work with actual data attributes from database
- Sort functionality sorts real data correctly
- Pagination returns correct page of real data
- API error responses are parsed and displayed correctly
- Loading spinners appear during API calls
- Optimistic updates (if used) rollback on failure

### G. State & Persistence Tests

Test that state is maintained correctly across sessions and tabs.

**Required tests (examples):**

- Refresh page mid-form - appropriate behavior (data kept or cleared)
- Close browser, reopen - session state handled correctly
- Same user in two browser tabs - changes sync or handled gracefully
- Browser back after form submit - no duplicate submission
- Bookmark a page, return later - works (with auth check)
- LocalStorage/cookies cleared - graceful re-authentication
- Unsaved changes warning when navigating away from dirty form

### H. URL & Direct Access Tests

Test direct URL access and URL manipulation security.

**Required tests (examples):**

- Change entity ID in URL - cannot access others' data
- Access /admin directly as regular user - blocked
- Malformed URL parameters - handled gracefully (no crash)
- Very long URL - handled correctly
- URL with SQL injection attempt - rejected/sanitized
- Deep link to deleted entity - shows "not found", not crash
- Query parameters for filters are reflected in UI
- Sharing a URL with filters preserves those filters

### I. Double-Action & Idempotency Tests

Test that rapid or duplicate actions don't cause issues.

**Required tests (examples):**

- Double-click submit button - only one record created
- Rapid multiple clicks on delete - only one deletion occurs
- Submit form, hit back, submit again - appropriate behavior
- Multiple simultaneous API calls - server handles correctly
- Refresh during save operation - data not corrupted
- Click same navigation link twice quickly - no issues
- Submit button disabled during processing

### J. Data Cleanup & Cascade Tests

Test that deleting data cleans up properly everywhere.

**Required tests (examples):**

- Delete parent entity - children removed from all views
- Delete item - removed from search results immediately
- Delete item - statistics/counts updated immediately
- Delete item - related dropdowns updated
- Delete item - cached views refreshed
- Soft delete (if applicable) - item hidden but recoverable
- Hard delete - item completely removed from database

### K. Default & Reset Tests

Test that defaults and reset functionality work correctly.

**Required tests (examples):**

- New form shows correct default values
- Date pickers default to sensible dates (today, not 1970)
- Dropdowns default to correct option (or placeholder)
- Reset button clears to defaults, not just empty
- Clear filters button resets all filters to default
- Pagination resets to page 1 when filters change
- Sorting resets when changing views

### L. Search & Filter Edge Cases

Test search and filter functionality thoroughly.

**Required tests (examples):**

- Empty search shows all results (or appropriate message)
- Search with only spaces - handled correctly
- Search with special characters (!@#$%^&\*) - no errors
- Search with quotes - handled correctly
- Search with very long string - handled correctly
- Filter combinations that return zero results - shows message
- Filter + search + sort together - all work correctly
- Filter persists after viewing detail and returning to list
- Clear individual filter - works correctly
- Search is case-insensitive (or clearly case-sensitive)

### M. Form Validation Tests

Test all form validation rules exhaustively.

**Required tests (examples):**

- Required field empty - shows error, blocks submit
- Email field with invalid email formats - shows error
- Password field - enforces complexity requirements
- Numeric field with letters - rejected
- Date field with invalid date - rejected
- Min/max length enforced on text fields
- Min/max values enforced on numeric fields
- Duplicate unique values rejected (e.g., duplicate email)
- Error messages are specific (not just "invalid")
- Errors clear when user fixes the issue
- Server-side validation matches client-side
- Whitespace-only input rejected for required fields

### N. Feedback & Notification Tests

Test that users get appropriate feedback for all actions.

**Required tests (examples):**

- Every successful save/create shows success feedback
- Every failed action shows error feedback
- Loading spinner during every async operation
- Disabled state on buttons during form submission
- Progress indicator for long operations (file upload)
- Toast/notification disappears after appropriate time
- Multiple notifications don't overlap incorrectly
- Success messages are specific (not just "Success")

### O. Responsive & Layout Tests

Test that the UI works on different screen sizes.

**Required tests (examples):**

- Desktop layout correct at 1920px width
- Tablet layout correct at 768px width
- Mobile layout correct at 375px width
- No horizontal scroll on any standard viewport
- Touch targets large enough on mobile (44px min)
- Modals fit within viewport on mobile
- Long text truncates or wraps correctly (no overflow)
- Tables scroll horizontally if needed on mobile
- Navigation collapses appropriately on mobile

### P. Accessibility Tests

Test basic accessibility compliance.

**Required tests (examples):**

- Tab navigation works through all interactive elements
- Focus ring visible on all focused elements
- Screen reader can navigate main content areas
- ARIA labels on icon-only buttons
- Color contrast meets WCAG AA (4.5:1 for text)
- No information conveyed by color alone
- Form fields have associated labels
- Error messages announced to screen readers
- Skip link to main content (if applicable)
- Images have alt text

### Q. Temporal & Timezone Tests

Test date/time handling.

**Required tests (examples):**

- Dates display in user's local timezone
- Created/updated timestamps accurate and formatted correctly
- Date picker allows only valid date ranges
- Overdue items identified correctly (timezone-aware)
- "Today", "This Week" filters work correctly for user's timezone
- Recurring items generate at correct times (if applicable)
- Date sorting works correctly across months/years

### R. Concurrency & Race Condition Tests

Test multi-user and race condition scenarios.

**Required tests (examples):**

- Two users edit same record - last save wins or conflict shown
- Record deleted while another user viewing - graceful handling
- List updates while user on page 2 - pagination still works
- Rapid navigation between pages - no stale data displayed
- API response arrives after user navigated away - no crash
- Concurrent form submissions from same user handled

### S. Export/Import Tests (if applicable)

Test data export and import functionality.

**Required tests (examples):**

- Export all data - file contains all records
- Export filtered data - only filtered records included
- Import valid file - all records created correctly
- Import duplicate data - handled correctly (skip/update/error)
- Import malformed file - error message, no partial import
- Export then import - data integrity preserved exactly

### T. Performance Tests

Test basic performance requirements.

**Required tests (examples):**

- Page loads in <3s with 100 records
- Page loads in <5s with 1000 records
- Search responds in <1s
- Infinite scroll doesn't degrade with many items
- Large file upload shows progress
- Memory doesn't leak on long sessions
- No console errors during normal operation

---

## ABSOLUTE PROHIBITION: NO MOCK DATA

The feature_list.json must include tests that **actively verify real data** and **detect mock data patterns**.

**Include these specific tests:**

1. Create unique test data (e.g., "TEST_12345_VERIFY_ME")
2. Verify that EXACT data appears in UI
3. Refresh page - data persists
4. Delete data - verify it's gone
5. If data appears that wasn't created during test - FLAG AS MOCK DATA

**The agent implementing features MUST NOT use:**

- Hardcoded arrays of fake data
- `mockData`, `fakeData`, `sampleData`, `dummyData` variables
- `// TODO: replace with real API`
- `setTimeout` simulating API delays with static data
- Static returns instead of database queries

---

**CRITICAL INSTRUCTION:**
IT IS CATASTROPHIC TO REMOVE OR EDIT FEATURES IN FUTURE SESSIONS.
Features can ONLY be marked as passing (via the `feature_mark_passing` tool with the feature_id).
Never remove features, never edit descriptions, never modify testing steps.
This ensures no functionality is missed.

### SECOND TASK: Create init.sh

Create a script called `init.sh` that future agents can use to quickly
set up and run the development environment. The script should:

1. Install any required dependencies
2. Start any necessary servers or services
3. Print helpful information about how to access the running application

Base the script on the technology stack specified in `app_spec.txt`.

### THIRD TASK: Initialize Git

Create a git repository and make your first commit with:

- init.sh (environment setup script)
- README.md (project overview and setup instructions)
- Any initial project structure files

Note: Features are stored in the SQLite database (features.db), not in a JSON file.

Commit message: "Initial setup: init.sh, project structure, and features created via API"

### FOURTH TASK: Create Project Structure

Set up the basic project structure based on what's specified in `app_spec.txt`.
This typically includes directories for frontend, backend, and any other
components mentioned in the spec.

### OPTIONAL: Start Implementation

If you have time remaining in this session, you may begin implementing
the highest-priority features. Get the next feature with:

```
Use the feature_get_next tool
```

Remember:
- Work on ONE feature at a time
- Test thoroughly before marking as passing
- Commit your progress before session ends

### ENDING THIS SESSION

Before your context fills up:

1. Commit all work with descriptive messages
2. Create `claude-progress.txt` with a summary of what you accomplished
3. Verify features were created using the feature_get_stats tool
4. Leave the environment in a clean, working state

The next agent will continue from here with a fresh context window.

---

**Remember:** You have unlimited time across many sessions. Focus on
quality over speed. Production-ready is the goal.


Now I have both the architecture and the initializer prompt template. Let me generate all the spec files:


Write

<project_specification>
  <project_name>AutoCoder++</project_name>

  <overview>
    AutoCoder++ is an enterprise-grade autonomous coding agent system built on the Claude Agent SDK. It employs a sophisticated two-agent pattern where an Initializer Agent analyzes application specifications and creates testable features, while a Coding Agent systematically implements each feature with verification. The system features a React-based UI for project management, real-time progress tracking via WebSocket, parallel agent execution with AI-driven scheduling, multi-model support (Opus/Sonnet/Haiku), intelligent caching, self-healing recovery, and comprehensive enterprise features including SSO, RBAC, and multi-tenant support.
  </overview>

  <technology_stack>
    <frontend>
      <framework>React 18 with TypeScript</framework>
      <styling>Tailwind CSS v4 with Neobrutalism theme</styling>
      <components>Radix UI primitives</components>
      <state_management>TanStack Query (React Query)</state_management>
      <visualization>D3.js for dependency graphs</visualization>
      <real_time>WebSocket client</real_time>
    </frontend>
    <backend>
      <runtime>Python 3.11+</runtime>
      <framework>FastAPI</framework>
      <orm>SQLAlchemy</orm>
      <database>SQLite (features.db, registry.db)</database>
      <async>asyncio</async>
    </backend>
    <ai_integration>
      <sdk>Claude Agent SDK</sdk>
      <api>Anthropic API</api>
      <models>
        <analysis>claude-opus-4 (architectural decisions, complex reasoning)</analysis>
        <coding>claude-sonnet-4-20250514 (fast implementation)</coding>
        <validation>claude-haiku-3 (quick validation, cost-effective)</validation>
      </models>
      <protocol>Model Context Protocol (MCP)</protocol>
    </ai_integration>
    <testing>
      <browser_automation>Playwright MCP</browser_automation>
      <unit_testing>pytest</unit_testing>
      <frontend_testing>Vitest</frontend_testing>
    </testing>
    <communication>
      <api>REST with FastAPI</api>
      <real_time>WebSocket</real_time>
    </communication>
  </technology_stack>

  <prerequisites>
    <environment_setup>
      - Python 3.11+ with pip
      - Node.js 18+ with npm
      - ANTHROPIC_API_KEY environment variable
      - Git for version control
    </environment_setup>
  </prerequisites>

  <feature_count>325</feature_count>

  <security_and_access_control>
    <user_roles>
      <role name="admin">
        <permissions>
          - Full system access
          - Manage all projects across all users
          - Configure global settings and resources
          - View audit logs and compliance reports
          - Manage user accounts and roles
          - Access cost analytics and budgets
          - Configure SSO and authentication settings
        </permissions>
        <protected_routes>
          - /admin/*
          - /settings/global/*
          - /users/*
          - /audit/*
          - /compliance/*
        </protected_routes>
      </role>
      <role name="user">
        <permissions>
          - Create and manage own projects
          - Run agents on own projects
          - View own project analytics
          - Configure project-level settings
          - Access own cost tracking
          - Cannot access other users' projects
          - Cannot access admin settings
        </permissions>
        <protected_routes>
          - /projects/* (own projects only)
          - /settings/account/*
        </protected_routes>
      </role>
      <role name="viewer">
        <permissions>
          - View assigned projects (read-only)
          - Cannot start/stop agents
          - Cannot modify features
          - Cannot change settings
        </permissions>
        <protected_routes>
          - /projects/:id/view (assigned projects only)
        </protected_routes>
      </role>
    </user_roles>
    <authentication>
      <method>Local accounts (email/password), OAuth (GitHub, Google), SSO (SAML/OIDC)</method>
      <session_timeout>24 hours with activity-based extension</session_timeout>
      <password_requirements>Minimum 8 characters, mixed case, numbers, special characters</password_requirements>
    </authentication>
    <sensitive_operations>
      - Delete project requires confirmation dialog
      - Delete user account requires password re-entry
      - Bulk operations require explicit confirmation
      - Budget changes require admin approval
      - SSO configuration changes require re-authentication
    </sensitive_operations>
  </security_and_access_control>

  <core_features>
    <agent_system>
      - Two-agent pattern (Initializer + Coding agents)
      - Agent lifecycle management (start, stop, pause, resume)
      - Session persistence and auto-continuation
      - Context-aware prompt loading with infrastructure injection
      - YOLO mode (skip testing for faster iteration)
      - Agent status tracking (idle, running, paused, crashed)
      - Subprocess isolation for agent execution
      - Automatic 3-second delay between sessions
      - Graceful shutdown and cleanup
    </agent_system>

    <parallel_execution>
      - Smart orchestrator for AI-driven parallelization
      - Concurrent agent spawning (configurable max)
      - File-level conflict detection via FeatureGraph
      - Async-safe file locking with FileLockManager
      - Parallel batch grouping of non-conflicting features
      - Result merging and verification
      - Conflict resolution with git-style markers
      - asyncio.Semaphore for concurrency control
    </parallel_execution>

    <multi_model_support>
      - ModelRouter for task-based model selection
      - Opus for architectural decisions and analysis
      - Sonnet for code implementation
      - Haiku for quick validations and cost optimization
      - Automatic fallback between models
      - Per-task model configuration
      - Model performance tracking
    </multi_model_support>

    <feature_management>
      - SQLite database for feature storage
      - Priority-based feature ordering
      - Category assignment (functional, style, etc.)
      - Test step definitions per feature
      - Status tracking (pending, in_progress, passes)
      - Bulk feature creation
      - Feature skipping and reordering
      - Regression testing on random passing features
      - MCP tools for feature operations
    </feature_management>

    <intelligent_caching>
      - Cache successful implementations by pattern
      - Similarity matching for feature approaches
      - Approach suggestions from past implementations
      - Token usage reduction through reuse
      - Project-specific knowledge base
      - Implementation recording with timing
      - Cross-project pattern learning
    </intelligent_caching>

    <self_healing_recovery>
      - Stuck state detection
      - Failure pattern analysis across sessions
      - Automatic workaround generation
      - Recovery strategy application
      - Learning from past failures
      - Infinite loop detection
      - Error pattern classification
      - Graceful degradation
    </self_healing_recovery>

    <ai_test_generation>
      - Auto-generate unit tests during implementation
      - Integration test generation for feature combinations
      - Edge case discovery via AI reasoning
      - Property-based test generation
      - Test coverage analysis
      - Mutation testing integration
      - Test step validation
    </ai_test_generation>

    <git_integration>
      - Auto-create feature branches
      - Meaningful commit messages from context
      - Auto-generate PR descriptions
      - AI-assisted conflict resolution
      - Branch management per feature
      - Merge handling and verification
      - Commit history tracking
    </git_integration>

    <real_time_collaboration>
      - Watch mode for file changes
      - Human editing while agent works
      - Conflict resolution with git-style markers
      - Pair programming mode
      - Live edit broadcasting
      - Human review requests
      - Edit acceptance workflow
    </real_time_collaboration>

    <cost_optimization>
      - Per-project token budgets
      - Real-time usage tracking
      - Cost estimation before starting
      - Automatic prompt optimization
      - Usage analytics and trends
      - Budget alerts and limits
      - Cost-per-feature tracking
      - Optimization suggestions
    </cost_optimization>

    <plugin_architecture>
      - Pre/post implementation hooks
      - Custom MCP tool registration
      - Custom validators
      - Custom reporters
      - Event-based plugin system
      - Plugin lifecycle management
      - Configuration per plugin
    </plugin_architecture>
  </core_features>

  <ui_features>
    <main_application>
      - Project selection dropdown
      - Kanban board (Pending -> In Progress -> Done)
      - Agent controls (Start/Stop/Pause/Resume)
      - YOLO mode toggle with lightning bolt icon
      - Real-time progress bar with animation
      - Log viewer with live updates
      - Dark/light mode toggle
    </main_application>

    <visual_progress_dashboard>
      - Dependency graph visualization (D3.js)
      - Real-time code diff viewer
      - Agent thought process timeline
      - Token usage analytics charts
      - Cost tracking per feature
      - Feature burndown chart
      - Session history timeline
      - Error rate visualization
    </visual_progress_dashboard>

    <project_management>
      - New project wizard (multi-step modal)
      - Import existing project
      - Project settings panel
      - Resource configuration
      - Credentials management
      - Project cloning
      - Archive/delete projects
    </project_management>

    <feature_board>
      - Draggable feature cards
      - Kanban columns with counts
      - Feature filtering and search
      - Category color coding
      - Priority indicators
      - Expand/collapse details
      - Bulk selection and actions
    </feature_board>

    <spec_creation>
      - Interactive spec wizard
      - WebSocket-based conversation
      - Guided question flow
      - Template selection
      - Preview before generation
    </spec_creation>

    <folder_browser>
      - Server-side filesystem navigation
      - Path selection for projects
      - File/folder icons
      - Quick navigation
    </folder_browser>

    <design_system>
      - Neobrutalism theme with bold borders
      - Hard shadows (4px black)
      - Vibrant color palette
      - CSS custom properties for theming
      - Monospace fonts for code
      - Slide-in animations
      - Pulse animations for status
      - Shimmer effect for progress
    </design_system>
  </ui_features>

  <enterprise_features>
    <authentication_sso>
      - Local email/password accounts
      - OAuth integration (GitHub, Google)
      - SAML SSO support
      - OIDC SSO support
      - Multi-factor authentication (optional)
      - Password reset flow
      - Email verification
      - Remember me functionality
    </authentication_sso>

    <rbac>
      - Role definitions (admin, user, viewer)
      - Permission assignments per role
      - Route protection by role
      - API endpoint authorization
      - Dynamic menu based on role
      - Permission inheritance
      - Custom role creation
    </rbac>

    <multi_tenant>
      - User isolation (data separation)
      - Project ownership tracking
      - Team management
      - Shared project access
      - Resource quotas per user
      - Tenant-specific settings
    </multi_tenant>

    <audit_compliance>
      - Action logging (who, what, when)
      - Login/logout tracking
      - Configuration change history
      - Data access logging
      - Compliance report generation
      - Log retention policies
      - Export audit data
    </audit_compliance>
  </enterprise_features>

  <database_schema>
    <tables>
      <features>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - priority (INTEGER NOT NULL DEFAULT 0)
        - category (TEXT NOT NULL)
        - name (TEXT NOT NULL)
        - description (TEXT NOT NULL)
        - steps (TEXT NOT NULL - JSON array)
        - passes (BOOLEAN NOT NULL DEFAULT FALSE)
        - in_progress (BOOLEAN NOT NULL DEFAULT FALSE)
        - created_at (TIMESTAMP DEFAULT CURRENT_TIMESTAMP)
        - updated_at (TIMESTAMP DEFAULT CURRENT_TIMESTAMP)
      </features>
      <projects>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - name (TEXT NOT NULL UNIQUE)
        - path (TEXT NOT NULL - POSIX format)
        - owner_id (INTEGER - FK to users)
        - created_at (TIMESTAMP DEFAULT CURRENT_TIMESTAMP)
        - last_accessed (TIMESTAMP)
      </projects>
      <users>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - email (TEXT NOT NULL UNIQUE)
        - password_hash (TEXT)
        - role (TEXT NOT NULL DEFAULT 'user')
        - oauth_provider (TEXT)
        - oauth_id (TEXT)
        - created_at (TIMESTAMP)
        - last_login (TIMESTAMP)
      </users>
      <sessions>
        - id (TEXT PRIMARY KEY)
        - user_id (INTEGER - FK to users)
        - project_id (INTEGER - FK to projects)
        - started_at (TIMESTAMP)
        - ended_at (TIMESTAMP)
        - status (TEXT)
        - tokens_used (INTEGER)
        - cost (REAL)
      </sessions>
      <audit_logs>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - user_id (INTEGER - FK to users)
        - action (TEXT NOT NULL)
        - resource_type (TEXT)
        - resource_id (INTEGER)
        - details (TEXT - JSON)
        - ip_address (TEXT)
        - created_at (TIMESTAMP)
      </audit_logs>
      <implementation_cache>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - feature_pattern (TEXT NOT NULL)
        - implementation (TEXT NOT NULL)
        - tokens_used (INTEGER)
        - duration_seconds (REAL)
        - success (BOOLEAN)
        - created_at (TIMESTAMP)
      </implementation_cache>
      <budgets>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - project_id (INTEGER - FK to projects)
        - max_tokens (INTEGER)
        - tokens_used (INTEGER DEFAULT 0)
        - alert_threshold (REAL DEFAULT 0.8)
        - created_at (TIMESTAMP)
        - updated_at (TIMESTAMP)
      </budgets>
      <plugins>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - name (TEXT NOT NULL UNIQUE)
        - enabled (BOOLEAN DEFAULT TRUE)
        - config (TEXT - JSON)
        - created_at (TIMESTAMP)
      </plugins>
      <file_locks>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - file_path (TEXT NOT NULL)
        - owner (TEXT NOT NULL)
        - acquired_at (TIMESTAMP)
        - expires_at (TIMESTAMP)
      </file_locks>
    </tables>
  </database_schema>

  <api_endpoints_summary>
    <projects>
      - GET /api/projects (list all projects)
      - POST /api/projects (create project)
      - GET /api/projects/:name (get project)
      - PUT /api/projects/:name (update project)
      - DELETE /api/projects/:name (delete project)
      - POST /api/projects/:name/import (import existing)
      - POST /api/projects/:name/clone (clone project)
      - GET /api/projects/:name/stats (project statistics)
    </projects>
    <features>
      - GET /api/features/:project (list features)
      - POST /api/features/:project/bulk (create bulk)
      - GET /api/features/:project/next (get next)
      - PUT /api/features/:id/status (update status)
      - GET /api/features/:project/stats (feature stats)
      - GET /api/features/:project/regression (get regression set)
      - PUT /api/features/:id/skip (skip feature)
    </features>
    <agent>
      - POST /api/agent/:project/start (start agent)
      - POST /api/agent/:project/stop (stop agent)
      - POST /api/agent/:project/pause (pause agent)
      - POST /api/agent/:project/resume (resume agent)
      - GET /api/agent/:project/status (get status)
      - GET /api/agent/:project/logs (get logs)
      - PUT /api/agent/:project/mode (set YOLO mode)
    </agent>
    <filesystem>
      - GET /api/filesystem/browse (browse folders)
      - GET /api/filesystem/validate (validate path)
    </filesystem>
    <spec>
      - WS /api/spec/ws (spec creation wizard)
      - POST /api/spec/generate (generate spec)
      - GET /api/spec/:project (get spec)
    </spec>
    <auth>
      - POST /api/auth/login (login)
      - POST /api/auth/logout (logout)
      - POST /api/auth/register (register)
      - POST /api/auth/refresh (refresh token)
      - GET /api/auth/me (current user)
      - POST /api/auth/password/reset (reset password)
      - GET /api/auth/oauth/:provider (OAuth redirect)
      - POST /api/auth/oauth/:provider/callback (OAuth callback)
    </auth>
    <users>
      - GET /api/users (list users - admin)
      - POST /api/users (create user - admin)
      - GET /api/users/:id (get user)
      - PUT /api/users/:id (update user)
      - DELETE /api/users/:id (delete user - admin)
      - PUT /api/users/:id/role (change role - admin)
    </users>
    <audit>
      - GET /api/audit/logs (get audit logs - admin)
      - GET /api/audit/export (export logs - admin)
    </audit>
    <analytics>
      - GET /api/analytics/usage (token usage)
      - GET /api/analytics/cost (cost tracking)
      - GET /api/analytics/performance (performance metrics)
    </analytics>
    <budgets>
      - GET /api/budgets/:project (get budget)
      - PUT /api/budgets/:project (update budget)
      - GET /api/budgets/:project/alerts (get alerts)
    </budgets>
    <plugins>
      - GET /api/plugins (list plugins)
      - POST /api/plugins (register plugin)
      - PUT /api/plugins/:id (update plugin)
      - DELETE /api/plugins/:id (remove plugin)
    </plugins>
    <cache>
      - GET /api/cache/implementations (list cached)
      - GET /api/cache/suggest/:pattern (get suggestions)
      - DELETE /api/cache/clear (clear cache)
    </cache>
    <websocket>
      - WS /ws/projects/:name (real-time updates)
      - WS /ws/collaboration/:project (live editing)
    </websocket>
  </api_endpoints_summary>

  <mcp_tools>
    <feature_mcp>
      - feature_get_stats (progress statistics)
      - feature_get_next (highest-priority pending)
      - feature_get_for_regression (random passing features)
      - feature_mark_passing (mark complete)
      - feature_mark_in_progress (mark working)
      - feature_skip (move to end of queue)
      - feature_create_bulk (initialize all features)
    </feature_mcp>
    <playwright_mcp>
      - Browser automation for testing
      - Screenshot capture
      - DOM interaction
      - Network monitoring
    </playwright_mcp>
  </mcp_tools>

  <ui_layout>
    <main_structure>
      - Responsive layout with collapsible sidebar
      - Header with project selector, user menu, theme toggle
      - Main content area with Kanban board
      - Floating agent control panel
      - Slide-out log viewer
      - Modal overlays for wizards and forms
    </main_structure>
    <dashboard_layout>
      - Grid of analytics cards
      - Full-width dependency graph
      - Split view for diff viewer
      - Timeline for agent activity
    </dashboard_layout>
  </ui_layout>

  <design_system>
    <color_palette>
      - neo-pending: #fbbf24 (Yellow - pending features)
      - neo-progress: #22d3ee (Cyan - in progress)
      - neo-done: #22c55e (Green - completed)
      - neo-error: #ef4444 (Red - errors)
      - neo-bg: #f5f5f4 (Light background)
      - neo-bg-dark: #1c1917 (Dark background)
      - neo-border: #000000 (Bold borders)
      - neo-accent: #8b5cf6 (Purple accent)
    </color_palette>
    <typography>
      - Headings: Inter or system-ui
      - Code: JetBrains Mono or monospace
      - Body: Inter or system-ui
    </typography>
    <spacing>
      - Base unit: 4px
      - Border width: 4px
      - Shadow offset: 4px 4px
      - Border radius: 8px (slight rounding with brutal aesthetic)
    </spacing>
    <animations>
      - animate-slide-in: Card entrance (0.3s ease-out)
      - animate-pulse-neo: Status indicator pulse
      - animate-shimmer: Progress bar shimmer effect
      - animate-bounce-subtle: Button hover feedback
    </animations>
  </design_system>

  <implementation_steps>
    <step number="1">
      <title>Phase 1: Core Agent System</title>
      <tasks>
        - Set up Python project structure with FastAPI
        - Implement Claude SDK client configuration
        - Create agent session loop (agent.py)
        - Implement MCP server for feature management
        - Create SQLite database models
        - Build basic prompt loading system
        - Implement agent lifecycle (start/stop/pause)
      </tasks>
    </step>
    <step number="2">
      <title>Phase 2: Feature Management</title>
      <tasks>
        - Implement feature CRUD operations
        - Build bulk feature creation
        - Create priority-based scheduling
        - Implement feature status tracking
        - Build regression test selection
        - Create MCP tools for all feature operations
      </tasks>
    </step>
    <step number="3">
      <title>Phase 3: React UI Foundation</title>
      <tasks>
        - Set up React 18 + TypeScript project
        - Configure Tailwind CSS v4 with Neobrutalism theme
        - Create component library (Radix UI base)
        - Implement project selector
        - Build Kanban board with drag-drop
        - Create agent control panel
        - Implement WebSocket connection for real-time updates
      </tasks>
    </step>
    <step number="4">
      <title>Phase 4: Git Integration + Cost Optimization</title>
      <tasks>
        - Implement GitIntegration service
        - Auto-create feature branches
        - Generate meaningful commit messages
        - Build PR description generator
        - Implement token budget management
        - Create cost tracking per session/feature
        - Build usage analytics
      </tasks>
    </step>
    <step number="5">
      <title>Phase 5: Multi-Model Support + Intelligent Caching</title>
      <tasks>
        - Implement ModelRouter for task-based selection
        - Configure Opus/Sonnet/Haiku routing
        - Build implementation cache system
        - Create similarity matching for approaches
        - Implement suggestion system
        - Build project knowledge base
      </tasks>
    </step>
    <step number="6">
      <title>Phase 6: Parallel Execution</title>
      <tasks>
        - Implement SmartOrchestrator
        - Build FeatureGraph for conflict detection
        - Create FileLockManager (async-safe)
        - Implement parallel agent spawning
        - Build result merging system
        - Create conflict resolution
      </tasks>
    </step>
    <step number="7">
      <title>Phase 7: Self-Healing + Test Generation</title>
      <tasks>
        - Implement stuck state detection
        - Build failure pattern analyzer
        - Create recovery strategy generator
        - Implement AI-driven test generation
        - Build unit test auto-generation
        - Create integration test generation
        - Implement edge case discovery
      </tasks>
    </step>
    <step number="8">
      <title>Phase 8: Visual Dashboard + Collaboration</title>
      <tasks>
        - Implement D3.js dependency graph
        - Build real-time diff viewer
        - Create agent thought timeline
        - Build token analytics charts
        - Implement watch mode for files
        - Create live edit broadcasting
        - Build human review request system
      </tasks>
    </step>
    <step number="9">
      <title>Phase 9: Plugin Architecture</title>
      <tasks>
        - Design hook system (pre/post events)
        - Implement plugin registration
        - Create custom MCP tool support
        - Build validator plugin interface
        - Implement reporter plugins
        - Create plugin configuration UI
      </tasks>
    </step>
    <step number="10">
      <title>Phase 10: Enterprise Features</title>
      <tasks>
        - Implement local authentication
        - Add OAuth providers (GitHub, Google)
        - Build SSO support (SAML/OIDC)
        - Implement RBAC system
        - Create user management UI
        - Build multi-tenant isolation
        - Implement audit logging
        - Create compliance reports
      </tasks>
    </step>
  </implementation_steps>

  <success_criteria>
    <functionality>
      - Two-agent pattern works autonomously across sessions
      - All 74+ API endpoints functional and tested
      - Parallel execution correctly handles file conflicts
      - Multi-model routing optimizes cost vs capability
      - Self-healing recovers from common failure patterns
      - Enterprise auth supports local, OAuth, and SSO
    </functionality>
    <user_experience>
      - Kanban board provides clear project visibility
      - Real-time updates reflect agent progress immediately
      - Agent controls are intuitive and responsive
      - Visual dashboard provides actionable insights
      - Collaboration mode enables seamless pair programming
    </user_experience>
    <technical_quality>
      - All code passes linting and type checking
      - Unit test coverage > 80%
      - Integration tests for all critical paths
      - No mock data in production
      - Proper error handling throughout
      - Secure authentication and authorization
    </technical_quality>
    <design_polish>
      - Neobrutalism theme consistently applied
      - Animations smooth and purposeful
      - Responsive on desktop and tablet
      - Accessible (WCAG AA compliance)
      - Dark/light mode fully functional
    </design_polish>
    <performance>
      - Page loads < 3 seconds
      - Real-time updates < 100ms latency
      - Handles 1000+ features without degradation
      - Memory stable over long sessions
    </performance>
  </success_criteria>
</project_specification>


File created successfully at: C:\Users\MikeSwanson\claude-projects\ACPP\AutoCoder-Plus-Plus\prompts\app_spec.txt

<project_specification>
  <project_name>AutoCoder++</project_name>

  <overview>
    AutoCoder++ is an enterprise-grade autonomous coding agent system built on the Claude Agent SDK. It employs a sophisticated two-agent pattern where an Initializer Agent analyzes application specifications and creates testable features, while a Coding Agent systematically implements each feature with verification. The system features a React-based UI for project management, real-time progress tracking via WebSocket, parallel agent execution with AI-driven scheduling, multi-model support (Opus/Sonnet/Haiku), intelligent caching, self-healing recovery, and comprehensive enterprise features including SSO, RBAC, and multi-tenant support.
  </overview>

  <technology_stack>
    <frontend>
      <framework>React 18 with TypeScript</framework>
      <styling>Tailwind CSS v4 with Neobrutalism theme</styling>
      <components>Radix UI primitives</components>
      <state_management>TanStack Query (React Query)</state_management>
      <visualization>D3.js for dependency graphs</visualization>
      <real_time>WebSocket client</real_time>
    </frontend>
    <backend>
      <runtime>Python 3.11+</runtime>
      <framework>FastAPI</framework>
      <orm>SQLAlchemy</orm>
      <database>SQLite (features.db, registry.db)</database>
      <async>asyncio</async>
    </backend>
    <ai_integration>
      <sdk>Claude Agent SDK</sdk>
      <api>Anthropic API</api>
      <models>
        <analysis>claude-opus-4 (architectural decisions, complex reasoning)</analysis>
        <coding>claude-sonnet-4-20250514 (fast implementation)</coding>
        <validation>claude-haiku-3 (quick validation, cost-effective)</validation>
      </models>
      <protocol>Model Context Protocol (MCP)</protocol>
    </ai_integration>
    <testing>
      <browser_automation>Playwright MCP</browser_automation>
      <unit_testing>pytest</unit_testing>
      <frontend_testing>Vitest</frontend_testing>
    </testing>
    <communication>
      <api>REST with FastAPI</api>
      <real_time>WebSocket</real_time>
    </communication>
  </technology_stack>

  <prerequisites>
    <environment_setup>
      - Python 3.11+ with pip
      - Node.js 18+ with npm
      - ANTHROPIC_API_KEY environment variable
      - Git for version control
    </environment_setup>
  </prerequisites>

  <feature_count>325</feature_count>

  <security_and_access_control>
    <user_roles>
      <role name="admin">
        <permissions>
          - Full system access
          - Manage all projects across all users
          - Configure global settings and resources
          - View audit logs and compliance reports
          - Manage user accounts and roles
          - Access cost analytics and budgets
          - Configure SSO and authentication settings
        </permissions>
        <protected_routes>
          - /admin/*
          - /settings/global/*
          - /users/*
          - /audit/*
          - /compliance/*
        </protected_routes>
      </role>
      <role name="user">
        <permissions>
          - Create and manage own projects
          - Run agents on own projects
          - View own project analytics
          - Configure project-level settings
          - Access own cost tracking
          - Cannot access other users' projects
          - Cannot access admin settings
        </permissions>
        <protected_routes>
          - /projects/* (own projects only)
          - /settings/account/*
        </protected_routes>
      </role>
      <role name="viewer">
        <permissions>
          - View assigned projects (read-only)
          - Cannot start/stop agents
          - Cannot modify features
          - Cannot change settings
        </permissions>
        <protected_routes>
          - /projects/:id/view (assigned projects only)
        </protected_routes>
      </role>
    </user_roles>
    <authentication>
      <method>Local accounts (email/password), OAuth (GitHub, Google), SSO (SAML/OIDC)</method>
      <session_timeout>24 hours with activity-based extension</session_timeout>
      <password_requirements>Minimum 8 characters, mixed case, numbers, special characters</password_requirements>
    </authentication>
    <sensitive_operations>
      - Delete project requires confirmation dialog
      - Delete user account requires password re-entry
      - Bulk operations require explicit confirmation
      - Budget changes require admin approval
      - SSO configuration changes require re-authentication
    </sensitive_operations>
  </security_and_access_control>

  <core_features>
    <agent_system>
      - Two-agent pattern (Initializer + Coding agents)
      - Agent lifecycle management (start, stop, pause, resume)
      - Session persistence and auto-continuation
      - Context-aware prompt loading with infrastructure injection
      - YOLO mode (skip testing for faster iteration)
      - Agent status tracking (idle, running, paused, crashed)
      - Subprocess isolation for agent execution
      - Automatic 3-second delay between sessions
      - Graceful shutdown and cleanup
    </agent_system>

    <parallel_execution>
      - Smart orchestrator for AI-driven parallelization
      - Concurrent agent spawning (configurable max)
      - File-level conflict detection via FeatureGraph
      - Async-safe file locking with FileLockManager
      - Parallel batch grouping of non-conflicting features
      - Result merging and verification
      - Conflict resolution with git-style markers
      - asyncio.Semaphore for concurrency control
    </parallel_execution>

    <multi_model_support>
      - ModelRouter for task-based model selection
      - Opus for architectural decisions and analysis
      - Sonnet for code implementation
      - Haiku for quick validations and cost optimization
      - Automatic fallback between models
      - Per-task model configuration
      - Model performance tracking
    </multi_model_support>

    <feature_management>
      - SQLite database for feature storage
      - Priority-based feature ordering
      - Category assignment (functional, style, etc.)
      - Test step definitions per feature
      - Status tracking (pending, in_progress, passes)
      - Bulk feature creation
      - Feature skipping and reordering
      - Regression testing on random passing features
      - MCP tools for feature operations
    </feature_management>

    <intelligent_caching>
      - Cache successful implementations by pattern
      - Similarity matching for feature approaches
      - Approach suggestions from past implementations
      - Token usage reduction through reuse
      - Project-specific knowledge base
      - Implementation recording with timing
      - Cross-project pattern learning
    </intelligent_caching>

    <self_healing_recovery>
      - Stuck state detection
      - Failure pattern analysis across sessions
      - Automatic workaround generation
      - Recovery strategy application
      - Learning from past failures
      - Infinite loop detection
      - Error pattern classification
      - Graceful degradation
    </self_healing_recovery>

    <ai_test_generation>
      - Auto-generate unit tests during implementation
      - Integration test generation for feature combinations
      - Edge case discovery via AI reasoning
      - Property-based test generation
      - Test coverage analysis
      - Mutation testing integration
      - Test step validation
    </ai_test_generation>

    <git_integration>
      - Auto-create feature branches
      - Meaningful commit messages from context
      - Auto-generate PR descriptions
      - AI-assisted conflict resolution
      - Branch management per feature
      - Merge handling and verification
      - Commit history tracking
    </git_integration>

    <real_time_collaboration>
      - Watch mode for file changes
      - Human editing while agent works
      - Conflict resolution with git-style markers
      - Pair programming mode
      - Live edit broadcasting
      - Human review requests
      - Edit acceptance workflow
    </real_time_collaboration>

    <cost_optimization>
      - Per-project token budgets
      - Real-time usage tracking
      - Cost estimation before starting
      - Automatic prompt optimization
      - Usage analytics and trends
      - Budget alerts and limits
      - Cost-per-feature tracking
      - Optimization suggestions
    </cost_optimization>

    <plugin_architecture>
      - Pre/post implementation hooks
      - Custom MCP tool registration
      - Custom validators
      - Custom reporters
      - Event-based plugin system
      - Plugin lifecycle management
      - Configuration per plugin
    </plugin_architecture>
  </core_features>

  <ui_features>
    <main_application>
      - Project selection dropdown
      - Kanban board (Pending -> In Progress -> Done)
      - Agent controls (Start/Stop/Pause/Resume)
      - YOLO mode toggle with lightning bolt icon
      - Real-time progress bar with animation
      - Log viewer with live updates
      - Dark/light mode toggle
    </main_application>

    <visual_progress_dashboard>
      - Dependency graph visualization (D3.js)
      - Real-time code diff viewer
      - Agent thought process timeline
      - Token usage analytics charts
      - Cost tracking per feature
      - Feature burndown chart
      - Session history timeline
      - Error rate visualization
    </visual_progress_dashboard>

    <project_management>
      - New project wizard (multi-step modal)
      - Import existing project
      - Project settings panel
      - Resource configuration
      - Credentials management
      - Project cloning
      - Archive/delete projects
    </project_management>

    <feature_board>
      - Draggable feature cards
      - Kanban columns with counts
      - Feature filtering and search
      - Category color coding
      - Priority indicators
      - Expand/collapse details
      - Bulk selection and actions
    </feature_board>

    <spec_creation>
      - Interactive spec wizard
      - WebSocket-based conversation
      - Guided question flow
      - Template selection
      - Preview before generation
    </spec_creation>

    <folder_browser>
      - Server-side filesystem navigation
      - Path selection for projects
      - File/folder icons
      - Quick navigation
    </folder_browser>

    <design_system>
      - Neobrutalism theme with bold borders
      - Hard shadows (4px black)
      - Vibrant color palette
      - CSS custom properties for theming
      - Monospace fonts for code
      - Slide-in animations
      - Pulse animations for status
      - Shimmer effect for progress
    </design_system>
  </ui_features>

  <enterprise_features>
    <authentication_sso>
      - Local email/password accounts
      - OAuth integration (GitHub, Google)
      - SAML SSO support
      - OIDC SSO support
      - Multi-factor authentication (optional)
      - Password reset flow
      - Email verification
      - Remember me functionality
    </authentication_sso>

    <rbac>
      - Role definitions (admin, user, viewer)
      - Permission assignments per role
      - Route protection by role
      - API endpoint authorization
      - Dynamic menu based on role
      - Permission inheritance
      - Custom role creation
    </rbac>

    <multi_tenant>
      - User isolation (data separation)
      - Project ownership tracking
      - Team management
      - Shared project access
      - Resource quotas per user
      - Tenant-specific settings
    </multi_tenant>

    <audit_compliance>
      - Action logging (who, what, when)
      - Login/logout tracking
      - Configuration change history
      - Data access logging
      - Compliance report generation
      - Log retention policies
      - Export audit data
    </audit_compliance>
  </enterprise_features>

  <database_schema>
    <tables>
      <features>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - priority (INTEGER NOT NULL DEFAULT 0)
        - category (TEXT NOT NULL)
        - name (TEXT NOT NULL)
        - description (TEXT NOT NULL)
        - steps (TEXT NOT NULL - JSON array)
        - passes (BOOLEAN NOT NULL DEFAULT FALSE)
        - in_progress (BOOLEAN NOT NULL DEFAULT FALSE)
        - created_at (TIMESTAMP DEFAULT CURRENT_TIMESTAMP)
        - updated_at (TIMESTAMP DEFAULT CURRENT_TIMESTAMP)
      </features>
      <projects>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - name (TEXT NOT NULL UNIQUE)
        - path (TEXT NOT NULL - POSIX format)
        - owner_id (INTEGER - FK to users)
        - created_at (TIMESTAMP DEFAULT CURRENT_TIMESTAMP)
        - last_accessed (TIMESTAMP)
      </projects>
      <users>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - email (TEXT NOT NULL UNIQUE)
        - password_hash (TEXT)
        - role (TEXT NOT NULL DEFAULT 'user')
        - oauth_provider (TEXT)
        - oauth_id (TEXT)
        - created_at (TIMESTAMP)
        - last_login (TIMESTAMP)
      </users>
      <sessions>
        - id (TEXT PRIMARY KEY)
        - user_id (INTEGER - FK to users)
        - project_id (INTEGER - FK to projects)
        - started_at (TIMESTAMP)
        - ended_at (TIMESTAMP)
        - status (TEXT)
        - tokens_used (INTEGER)
        - cost (REAL)
      </sessions>
      <audit_logs>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - user_id (INTEGER - FK to users)
        - action (TEXT NOT NULL)
        - resource_type (TEXT)
        - resource_id (INTEGER)
        - details (TEXT - JSON)
        - ip_address (TEXT)
        - created_at (TIMESTAMP)
      </audit_logs>
      <implementation_cache>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - feature_pattern (TEXT NOT NULL)
        - implementation (TEXT NOT NULL)
        - tokens_used (INTEGER)
        - duration_seconds (REAL)
        - success (BOOLEAN)
        - created_at (TIMESTAMP)
      </implementation_cache>
      <budgets>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - project_id (INTEGER - FK to projects)
        - max_tokens (INTEGER)
        - tokens_used (INTEGER DEFAULT 0)
        - alert_threshold (REAL DEFAULT 0.8)
        - created_at (TIMESTAMP)
        - updated_at (TIMESTAMP)
      </budgets>
      <plugins>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - name (TEXT NOT NULL UNIQUE)
        - enabled (BOOLEAN DEFAULT TRUE)
        - config (TEXT - JSON)
        - created_at (TIMESTAMP)
      </plugins>
      <file_locks>
        - id (INTEGER PRIMARY KEY AUTOINCREMENT)
        - file_path (TEXT NOT NULL)
        - owner (TEXT NOT NULL)
        - acquired_at (TIMESTAMP)
        - expires_at (TIMESTAMP)
      </file_locks>
    </tables>
  </database_schema>

  <api_endpoints_summary>
    <projects>
      - GET /api/projects (list all projects)
      - POST /api/projects (create project)
      - GET /api/projects/:name (get project)
      - PUT /api/projects/:name (update project)
      - DELETE /api/projects/:name (delete project)
      - POST /api/projects/:name/import (import existing)
      - POST /api/projects/:name/clone (clone project)
      - GET /api/projects/:name/stats (project statistics)
    </projects>
    <features>
      - GET /api/features/:project (list features)
      - POST /api/features/:project/bulk (create bulk)
      - GET /api/features/:project/next (get next)
      - PUT /api/features/:id/status (update status)
      - GET /api/features/:project/stats (feature stats)
      - GET /api/features/:project/regression (get regression set)
      - PUT /api/features/:id/skip (skip feature)
    </features>
    <agent>
      - POST /api/agent/:project/start (start agent)
      - POST /api/agent/:project/stop (stop agent)
      - POST /api/agent/:project/pause (pause agent)
      - POST /api/agent/:project/resume (resume agent)
      - GET /api/agent/:project/status (get status)
      - GET /api/agent/:project/logs (get logs)
      - PUT /api/agent/:project/mode (set YOLO mode)
    </agent>
    <filesystem>
      - GET /api/filesystem/browse (browse folders)
      - GET /api/filesystem/validate (validate path)
    </filesystem>
    <spec>
      - WS /api/spec/ws (spec creation wizard)
      - POST /api/spec/generate (generate spec)
      - GET /api/spec/:project (get spec)
    </spec>
    <auth>
      - POST /api/auth/login (login)
      - POST /api/auth/logout (logout)
      - POST /api/auth/register (register)
      - POST /api/auth/refresh (refresh token)
      - GET /api/auth/me (current user)
      - POST /api/auth/password/reset (reset password)
      - GET /api/auth/oauth/:provider (OAuth redirect)
      - POST /api/auth/oauth/:provider/callback (OAuth callback)
    </auth>
    <users>
      - GET /api/users (list users - admin)
      - POST /api/users (create user - admin)
      - GET /api/users/:id (get user)
      - PUT /api/users/:id (update user)
      - DELETE /api/users/:id (delete user - admin)
      - PUT /api/users/:id/role (change role - admin)
    </users>
    <audit>
      - GET /api/audit/logs (get audit logs - admin)
      - GET /api/audit/export (export logs - admin)
    </audit>
    <analytics>
      - GET /api/analytics/usage (token usage)
      - GET /api/analytics/cost (cost tracking)
      - GET /api/analytics/performance (performance metrics)
    </analytics>
    <budgets>
      - GET /api/budgets/:project (get budget)
      - PUT /api/budgets/:project (update budget)
      - GET /api/budgets/:project/alerts (get alerts)
    </budgets>
    <plugins>
      - GET /api/plugins (list plugins)
      - POST /api/plugins (register plugin)
      - PUT /api/plugins/:id (update plugin)
      - DELETE /api/plugins/:id (remove plugin)
    </plugins>
    <cache>
      - GET /api/cache/implementations (list cached)
      - GET /api/cache/suggest/:pattern (get suggestions)
      - DELETE /api/cache/clear (clear cache)
    </cache>
    <websocket>
      - WS /ws/projects/:name (real-time updates)
      - WS /ws/collaboration/:project (live editing)
    </websocket>
  </api_endpoints_summary>

  <mcp_tools>
    <feature_mcp>
      - feature_get_stats (progress statistics)
      - feature_get_next (highest-priority pending)
      - feature_get_for_regression (random passing features)
      - feature_mark_passing (mark complete)
      - feature_mark_in_progress (mark working)
      - feature_skip (move to end of queue)
      - feature_create_bulk (initialize all features)
    </feature_mcp>
    <playwright_mcp>
      - Browser automation for testing
      - Screenshot capture
      - DOM interaction
      - Network monitoring
    </playwright_mcp>
  </mcp_tools>

  <ui_layout>
    <main_structure>
      - Responsive layout with collapsible sidebar
      - Header with project selector, user menu, theme toggle
      - Main content area with Kanban board
      - Floating agent control panel
      - Slide-out log viewer
      - Modal overlays for wizards and forms
    </main_structure>
    <dashboard_layout>
      - Grid of analytics cards
      - Full-width dependency graph
      - Split view for diff viewer
      - Timeline for agent activity
    </dashboard_layout>
  </ui_layout>

  <design_system>
    <color_palette>
      - neo-pending: #fbbf24 (Yellow - pending features)
      - neo-progress: #22d3ee (Cyan - in progress)
      - neo-done: #22c55e (Green - completed)
      - neo-error: #ef4444 (Red - errors)
      - neo-bg: #f5f5f4 (Light background)
      - neo-bg-dark: #1c1917 (Dark background)
      - neo-border: #000000 (Bold borders)
      - neo-accent: #8b5cf6 (Purple accent)
    </color_palette>
    <typography>
      - Headings: Inter or system-ui
      - Code: JetBrains Mono or monospace
      - Body: Inter or system-ui
    </typography>
    <spacing>
      - Base unit: 4px
      - Border width: 4px
      - Shadow offset: 4px 4px
      - Border radius: 8px (slight rounding with brutal aesthetic)
    </spacing>
    <animations>
      - animate-slide-in: Card entrance (0.3s ease-out)
      - animate-pulse-neo: Status indicator pulse
      - animate-shimmer: Progress bar shimmer effect
      - animate-bounce-subtle: Button hover feedback
    </animations>
  </design_system>

  <implementation_steps>
    <step number="1">
      <title>Phase 1: Core Agent System</title>
      <tasks>
        - Set up Python project structure with FastAPI
        - Implement Claude SDK client configuration
        - Create agent session loop (agent.py)
        - Implement MCP server for feature management
        - Create SQLite database models
        - Build basic prompt loading system
        - Implement agent lifecycle (start/stop/pause)
      </tasks>
    </step>
    <step number="2">
      <title>Phase 2: Feature Management</title>
      <tasks>
        - Implement feature CRUD operations
        - Build bulk feature creation
        - Create priority-based scheduling
        - Implement feature status tracking
        - Build regression test selection
        - Create MCP tools for all feature operations
      </tasks>
    </step>
    <step number="3">
      <title>Phase 3: React UI Foundation</title>
      <tasks>
        - Set up React 18 + TypeScript project
        - Configure Tailwind CSS v4 with Neobrutalism theme
        - Create component library (Radix UI base)
        - Implement project selector
        - Build Kanban board with drag-drop
        - Create agent control panel
        - Implement WebSocket connection for real-time updates
      </tasks>
    </step>
    <step number="4">
      <title>Phase 4: Git Integration + Cost Optimization</title>
      <tasks>
        - Implement GitIntegration service
        - Auto-create feature branches
        - Generate meaningful commit messages
        - Build PR description generator
        - Implement token budget management
        - Create cost tracking per session/feature
        - Build usage analytics
      </tasks>
    </step>
    <step number="5">
      <title>Phase 5: Multi-Model Support + Intelligent Caching</title>
      <tasks>
        - Implement ModelRouter for task-based selection
        - Configure Opus/Sonnet/Haiku routing
        - Build implementation cache system
        - Create similarity matching for approaches
        - Implement suggestion system
        - Build project knowledge base
      </tasks>
    </step>
    <step number="6">
      <title>Phase 6: Parallel Execution</title>
      <tasks>
        - Implement SmartOrchestrator
        - Build FeatureGraph for conflict detection
        - Create FileLockManager (async-safe)
        - Implement parallel agent spawning
        - Build result merging system
        - Create conflict resolution
      </tasks>
    </step>
    <step number="7">
      <title>Phase 7: Self-Healing + Test Generation</title>
      <tasks>
        - Implement stuck state detection
        - Build failure pattern analyzer
        - Create recovery strategy generator
        - Implement AI-driven test generation
        - Build unit test auto-generation
        - Create integration test generation
        - Implement edge case discovery
      </tasks>
    </step>
    <step number="8">
      <title>Phase 8: Visual Dashboard + Collaboration</title>
      <tasks>
        - Implement D3.js dependency graph
        - Build real-time diff viewer
        - Create agent thought timeline
        - Build token analytics charts
        - Implement watch mode for files
        - Create live edit broadcasting
        - Build human review request system
      </tasks>
    </step>
    <step number="9">
      <title>Phase 9: Plugin Architecture</title>
      <tasks>
        - Design hook system (pre/post events)
        - Implement plugin registration
        - Create custom MCP tool support
        - Build validator plugin interface
        - Implement reporter plugins
        - Create plugin configuration UI
      </tasks>
    </step>
    <step number="10">
      <title>Phase 10: Enterprise Features</title>
      <tasks>
        - Implement local authentication
        - Add OAuth providers (GitHub, Google)
        - Build SSO support (SAML/OIDC)
        - Implement RBAC system
        - Create user management UI
        - Build multi-tenant isolation
        - Implement audit logging
        - Create compliance reports
      </tasks>
    </step>
  </implementation_steps>

  <success_criteria>
    <functionality>
      - Two-agent pattern works autonomously across sessions
      - All 74+ API endpoints functional and tested
      - Parallel execution correctly handles file conflicts
      - Multi-model routing optimizes cost vs capability
      - Self-healing recovers from common failure patterns
      - Enterprise auth supports local, OAuth, and SSO
    </functionality>
    <user_experience>
      - Kanban board provides clear project visibility
      - Real-time updates reflect agent progress immediately
      - Agent controls are intuitive and responsive
      - Visual dashboard provides actionable insights
      - Collaboration mode enables seamless pair programming
    </user_experience>
    <technical_quality>
      - All code passes linting and type checking
      - Unit test coverage > 80%
      - Integration tests for all critical paths
      - No mock data in production
      - Proper error handling throughout
      - Secure authentication and authorization
    </technical_quality>
    <design_polish>
      - Neobrutalism theme consistently applied
      - Animations smooth and purposeful
      - Responsive on desktop and tablet
      - Accessible (WCAG AA compliance)
      - Dark/light mode fully functional
    </design_polish>
    <performance>
      - Page loads < 3 seconds
      - Real-time updates < 100ms latency
      - Handles 1000+ features without degradation
      - Memory stable over long sessions
    </performance>
  </success_criteria>
</project_specification>


Edit

**CRITICAL:** You must create exactly **[FEATURE_COUNT]** features using the `feature_create_bulk` tool.

**CRITICAL:** You must create exactly **325** features using the `feature_create_bulk` tool.