Summary
PAI's SYSTEM/USER two-tier architecture (documented in SYSTEM/SYSTEM_USER_EXTENDABILITY.md) protects USER-tier customizations during updates. However, it doesn't address a common real-world scenario: users who fix bugs in SYSTEM-tier files before those fixes are merged upstream.
When a user patches a SYSTEM file locally (e.g., fixing a bug in UpdateCounts.ts or statusline-command.sh), that fix gets silently overwritten on the next PAI update. There's no mechanism to detect, warn about, or preserve these local modifications.
Real-World Examples
Example 1: UpdateCounts.ts (see #642)
A user fixes the missing work/research/ratings counters. The fix lives in hooks/handlers/UpdateCounts.ts — a SYSTEM file. Next PAI release overwrites it with the old broken version.
Example 2: Generated files with cached identity
SKILL.md is generated by CreateDynamicCore.ts and caches {DAIDENTITY.NAME} at build time. After a PAI update that ships a new SKILL.md, the user's identity reverts to the default "PAI" instead of their configured name. There's no auto-rebuild trigger.
Proposed Solution
Three lightweight mechanisms that extend the existing SYSTEM/USER architecture:
1. LOCAL_PATCHES.md Convention
A standardized file at ~/.claude/LOCAL_PATCHES.md where users (or their DA) track local modifications to SYSTEM files:
# Local Patches to PAI SYSTEM Files
## Active Patches
### UpdateCounts.ts - Missing counters
**File:** hooks/handlers/UpdateCounts.ts
**Issue:** #642
**PR:** _pending_
- Checked by the DA before modifying SYSTEM files
- Serves as a pre/post-update checklist
- Could be read by an install/update script to warn about conflicts
2. PAIUpgrade Conflict Check
Add a step to the PAIUpgrade Upgrade workflow (between scoring and output) that:
- Reads
LOCAL_PATCHES.md if it exists
- Cross-references recommended techniques against locally-patched files
- Flags conflicts in the upgrade report with a
⚠️ LOCAL PATCH CONFLICT warning
This makes the upgrade workflow aware of local state, which is consistent with Thread 1's existing PAI State analysis.
3. Stale Generated File Detection
For generated files like SKILL.md, a lightweight check (in SessionStart or the install process) that compares settings.json mtime against SKILL.md mtime. If settings is newer, auto-rebuild:
if [ "$SETTINGS_FILE" -nt "$SKILL_MD" ]; then
bun ~/.claude/skills/PAI/Tools/CreateDynamicCore.ts
fi
This prevents the class of bug where identity/config changes don't propagate to generated files.
How This Fits the Architecture
- Extends the SYSTEM/USER pattern, doesn't replace it
- USER files remain protected by the existing architecture
- SYSTEM file patches get a tracking mechanism until they're upstreamed
- Generated files get a staleness check
- PAIUpgrade becomes aware of local state (consistent with its user-context-first design)
Scope
This is a feature proposal, not a PR. Happy to contribute implementation if the approach is approved.
Related: #642 (the bug that surfaced this gap)
Summary
PAI's SYSTEM/USER two-tier architecture (documented in
SYSTEM/SYSTEM_USER_EXTENDABILITY.md) protects USER-tier customizations during updates. However, it doesn't address a common real-world scenario: users who fix bugs in SYSTEM-tier files before those fixes are merged upstream.When a user patches a SYSTEM file locally (e.g., fixing a bug in
UpdateCounts.tsorstatusline-command.sh), that fix gets silently overwritten on the next PAI update. There's no mechanism to detect, warn about, or preserve these local modifications.Real-World Examples
Example 1: UpdateCounts.ts (see #642)
A user fixes the missing
work/research/ratingscounters. The fix lives inhooks/handlers/UpdateCounts.ts— a SYSTEM file. Next PAI release overwrites it with the old broken version.Example 2: Generated files with cached identity
SKILL.mdis generated byCreateDynamicCore.tsand caches{DAIDENTITY.NAME}at build time. After a PAI update that ships a new SKILL.md, the user's identity reverts to the default "PAI" instead of their configured name. There's no auto-rebuild trigger.Proposed Solution
Three lightweight mechanisms that extend the existing SYSTEM/USER architecture:
1.
LOCAL_PATCHES.mdConventionA standardized file at
~/.claude/LOCAL_PATCHES.mdwhere users (or their DA) track local modifications to SYSTEM files:2. PAIUpgrade Conflict Check
Add a step to the PAIUpgrade Upgrade workflow (between scoring and output) that:
LOCAL_PATCHES.mdif it exists⚠️ LOCAL PATCH CONFLICTwarningThis makes the upgrade workflow aware of local state, which is consistent with Thread 1's existing PAI State analysis.
3. Stale Generated File Detection
For generated files like
SKILL.md, a lightweight check (in SessionStart or the install process) that comparessettings.jsonmtime againstSKILL.mdmtime. If settings is newer, auto-rebuild:This prevents the class of bug where identity/config changes don't propagate to generated files.
How This Fits the Architecture
Scope
This is a feature proposal, not a PR. Happy to contribute implementation if the approach is approved.
Related: #642 (the bug that surfaced this gap)