# Issue: Custom routes not preserved in router.tsx

**Status**: Resolved
**Priority**: High
**Created**: 2026-01-26

## Problem

When router.tsx is regenerated, any custom routes that were manually added (for custom pages not generated by Prism) are lost.

Example: Custom pages like `/analyze` with map functionality need to be manually re-added to router.tsx after each generation.

## Impact

Developers must manually restore custom routes after every code generation, which is:
- Time-consuming
- Error-prone (easy to forget routes)
- Frustrating for iterative development workflows

## Proposed Solution

Consider one of these approaches:

1. **GENERATE_ONCE strategy for router.tsx**
   - Simple but prevents router updates from new models

2. **Protected region markers for custom routes**
   - Add `// PROTECTED_REGION_START(custom_routes)` markers
   - Preserve content within markers during regeneration

3. **Separate custom-routes file**
   - Support `custom-routes.tsx` that gets merged into main router
   - Cleanest separation but more complex implementation

Recommendation: Option 2 (protected regions) provides the best balance of flexibility and implementation complexity.

## Resolution

Implemented Option 2 (protected regions):

1. Changed router.tsx from `ALWAYS_OVERWRITE` to `MERGE` file strategy
2. Added three protected regions in the router template:
   - `// PRISM:PROTECTED:START - Custom Imports` - for custom page imports
   - `// PRISM:PROTECTED:START - Custom Routes` - for custom route definitions
   - `{/* PRISM:PROTECTED:START - Custom Nav Links */}` - for custom navigation

Custom code within these regions is now preserved during regeneration.
