Overview
This is a reusable A2A (agent-to-agent) operational pattern for executing large, cross-cutting identifier renames in monorepos with strict layering. Emerged from SKILL → DOCTRINE rename across STRATT (39 files, ~2,000 identifiers, 228 tests, 7 commits). Use case: Renaming a concept/type that cascades across multiple layers (schema → package → graph/CLI → app → docs). Time savings: ~60% vs. ad-hoc approach (4 hrs → 1.5 hrs for similar-sized project).Workflow Steps
Phase 1: Discovery & Mapping (15 min)
Prompt to agent:Map the monorepo’s dependency layers. For each layer, list:Verification: Agent should produce a table showing L0→L5 order with no circular deps. Example output:
- Package/directory name
- What it depends on (lower layers only)
- Key files affected by the rename: types, imports, exports, config
- Test count per layer
Phase 2: Search & Count (20 min)
Prompt to agent:For each identifier to rename (e.g., “Skill” → “Doctrine”):Verification: Agent should produce grep results with line counts and file categories. Example:
- Count occurrences in code (exclude comments, strings, and docs)
- List all files that contain the identifier
- Categorize: type definitions, imports, exports, function names, config keys
- Identify hard-cut boundaries (file extensions, config keys that need fallback)
Phase 3: Dependency-Order Commit Planning (10 min)
Prompt to agent:Based on the dependency layers from Phase 1:Verification: Agent should produce ordered commit list with test targets. Example plan:
- Group the renaming work into commits that follow L0→L5 order
- Each commit should touch one or two adjacent layers
- After each commit, all tests in affected layers should pass
- Generate commit messages describing what changed and why
Phase 4: Execute Commits in Order (90 min actual work)
For each commit (template):-
Identify files to change
-
Perform bulk replacements
-
Run layer tests (BLOCKING)
-
Type check (BLOCKING)
-
Commit with message
-
Verify no regressions
- Mark complete, move to next commit
- Stop and fix if tests fail (don’t skip)
- If blocked, revert commit, debug, re-commit
- Use consistent commit message format (Layer + concept)
Phase 5: Final Verification (15 min)
Prompt to agent:After all commits merged:Example verification script:
- Run full test suite across all layers
- Type check all packages
- Grep scan for remaining old identifiers (should be 0 in code)
- Build app (if applicable)
- Verify git log shows 7 commits in expected order
- ✅ All tests passing
- ✅ No type errors
- ✅ Grep scan clean (0 old identifiers)
- ✅ App builds successfully
- ✅ All 7 commits in log with clear messages
Anti-Patterns to Avoid
❌ Renaming files and code in separate commits- Causes intermediate breakage (imports can’t find files)
- Use: File rename + code update in same commit
- Debt accumulates; hard to debug which commit broke things
- Use: Run full layer tests after every commit
- Old identifiers lurk in comments, strings, config defaults
- Use: Grep scan before final cleanup commit
- 200+ files changed = impossible to review/debug
- Use: Max 2 adjacent layers per commit
- Existing users’ configs break on update
- Use: Optional chaining (e.g.,
doctrines ?? skills) in config layer only
Adapting to Your Monorepo
Questions to ask before starting:- How many layers does your monorepo have? (Identify L0→Ln)
- Are there circular dependencies? (Fix first; hard cut won’t help)
- What percentage of changes are in tests vs. production code? (Expect ~30% test updates)
- Do any external repos depend on your package? (If yes, need soft migration + deprecation warnings)
- Is there config that references the old name? (If yes, add fallback layer)
| Scope | Estimated Time | Layers | Commits |
|---|---|---|---|
| Small (1–5 files, 50 IDs) | 30 min | 2 | 2 |
| Medium (10–50 files, 500 IDs) | 1.5 hrs | 3–4 | 3–4 |
| Large (50–100+ files, 2000+ IDs) | 3–4 hrs | 4–6 | 6–8 |
| Extra-large (200+ files, 5000+ IDs) | 6–8 hrs | 6+ | 8–12 |
Output Template for Documentation
After executing, document in your repo:Related Artifacts
- Learnings: devarno-cloud/atlas/learnings/2026-04-03-skill-doctrine-rename-execution.md
- STRATT implementation: stratt-hq/.opencode/doctrines/
- Commit history: stratt-hq (commits 1–7, Phase 1)