#15284: perf(workspace): lazy-load templates only for missing files
agents
size: S
Cluster:
Workspace Path Fixes
## Summary
Reduces unnecessary file I/O during workspace setup by only loading templates for files that are actually missing.
**Supersedes #5927** (rebased on main, workspace optimization only; Chrome extension changes no longer needed).
### Problem
Previously, `ensureAgentWorkspace` loaded all 7 template files on every startup, even when all workspace files already existed. This was wasteful for the common case (existing workspace).
### Solution
1. Check which workspace files are missing first
2. Only load templates for files that need to be created
3. Process missing files in parallel for efficiency
### Impact
For existing workspaces (the common case), this eliminates ~7 template file reads per startup.
### Testing
- [x] `pnpm run lint` passes
- [x] `vitest run src/agents/workspace.test.ts` - all 4 tests pass
### AI Disclosure
🤖 This PR was AI-assisted (Claude via OpenClaw). I understand the changes and have tested them locally.
Most Similar PRs
#21553: fix: resolve workspace template dir in bundled dist/ layout
by echoVic · 2026-02-20
63.2%
#19482: fix(agents): only seed HEARTBEAT.md on brand-new workspaces
by CornBrother0x · 2026-02-17
63.1%
#17488: fix(agents): skip workspace deletion when shared with other agents
by soumikbhatta · 2026-02-15
62.1%
#22917: fix: Use agent's configured workspace when spawned as subagent
by jriff · 2026-02-21
62.0%
#7496: feat: add copy-templates script and workspace template resolution
by ThinkIbrokeIt · 2026-02-02
61.9%
#2884: fix: Create memory directory and symlink identity files during work...
by webdevtodayjason · 2026-01-27
61.3%
#15568: feat: configurable workspace context files (agents.defaults.context...
by koatora20 · 2026-02-13
59.8%
#20267: feat: workspace-aware post-compaction context
by nickjlamb · 2026-02-18
59.6%
#22439: feat(workspace): add tiered bootstrap loading with configurable boo...
by 882soft · 2026-02-21
59.6%
#22786: fix: guard against undefined file.path in system-prompt-report
by miloudbelarebia · 2026-02-21
59.5%