agentleFS
ROCmROCm/rocprofiler-systems-skills/skills/architecture-analyze/SKILL.md

architecture-analyze

Skill5 starsChanged 17 days agoMITView on GitHub

Analyze architectural changes - review module boundaries, dependencies, testability, and suggest simplifications. Used by pr-review and planning skills.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 10 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Reads memory first: - Check what you already know about this codebase's architecture

    line 12
  2. Distinctive:

    Spawns an Explore agent: - Only for areas not covered by memory

    line 13
  3. Distinctive:

    Read the memory file

    line 102
  4. Distinctive:

    Check if relevant modules are already documented

    line 103
  5. Distinctive:

    Only explore areas NOT covered by memory

    line 104
  6. Distinctive:

    Use memory to provide context for new analysis

    line 105
  7. Distinctive:

    Create memory file after analysis

    line 109
  8. Distinctive:

    Only add confirmed patterns (not speculation)

    line 469
  9. Distinctive:

    Update existing entries if they change

    line 470
  10. Distinctive:

    Keep memory concise and useful

    line 472

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Architecture Analyze Skill

Analyze proposed architectural changes or validate designs before implementation.

<IMPORTANT> This skill: 1. **Reads memory first** - Check what you already know about this codebase's architecture 2. **Spawns an Explore agent** - Only for areas not covered by memory 3. **Updates memory after** - Persist new architectural knowledge for future reviews

Memory location: ~/.claude/projects/<project>/memory/agents/architecture.md </IMPORTANT>

When to Use

ContextTrigger
PR ReviewInvoked by pr-review when architectural changes detected
PlanningInvoked by planning-feature to validate design before coding
StandaloneUser asks to analyze architecture of proposed changes

Detecting Architectural Changes

Invoke this skill when PR/changes include:

SignalExample
New directoriessrc/new_module/ created
New/changed interfacesAbstract class added, virtual methods changed
Factory/DI changesObject creation patterns modified
New CMake targetsadd_library(new_component ...)
Cross-module changes5+ files across different directories
New dependenciesExternal library added
Base class changesCore/foundation classes modified

Analysis Process

┌─────────────────────────────────────────────────────────────────┐
│                 Phase 0: Read Architecture Memory                │
│         Load existing knowledge about this codebase              │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                 Phase 1: Explore (if needed)                     │
│         Spawn Explore agent only for unknown areas               │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                 Phase 2: Analyze Module Boundaries               │
│         Where does new code belong? Proper separation?           │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                 Phase 3: Analyze Dependencies                    │
│         Direction correct? Cycles? Coupling level?               │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                 Phase 4: Assess Testability                      │
│         Isolation possible? Dependencies injectable?             │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                 Phase 5: Simplicity Check                        │
│         Over-engineered? Simpler alternative exists?             │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                 Phase 6: Generate Report                         │
│         Findings, concerns, recommendations                      │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                 Phase 7: Update Architecture Memory              │
│         Persist new knowledge for future reviews                 │
└─────────────────────────────────────────────────────────────────┘

Phase 0: Read Architecture Memory

Before exploring, check what you already know:

# Memory file location
~/.claude/projects/<project>/memory/agents/architecture.md

If memory exists:

  1. Read the memory file
  2. Check if relevant modules are already documented
  3. Only explore areas NOT covered by memory
  4. Use memory to provide context for new analysis

If memory doesn't exist:

  1. Proceed to full exploration (Phase 1)
  2. Create memory file after analysis

Phase 1: Explore Existing Architecture

Spawn an Explore agent with thoroughness "medium" or "very thorough":

Prompt for Explore agent:
"Analyze the existing architecture of this codebase focusing on:
1. Module/directory structure and their responsibilities
2. Key interfaces and abstract classes
3. Dependency patterns (how modules connect)
4. Factory/creation patterns used
5. How similar features were implemented before

Context: [describe the proposed changes or feature]

Return:
- Module map with responsibilities
- Key abstractions and interfaces
- Dependency graph (which modules depend on which)
- Patterns used for similar features"

What to Learn

AspectQuestions to Answer
Module structureWhat are the main modules? What does each do?
BoundariesWhere are the clear separation points?
InterfacesWhat abstractions exist? How are they used?
DependenciesHow do modules communicate? Direct or via interfaces?
PatternsWhat patterns are used? Factory? Strategy? Observer?
ConventionsHow were similar features added before?

Phase 2: Analyze Module Boundaries

Check Placement

QuestionGoodBad
Is code in the right module?Feature X in features/x/Feature X scattered across unrelated modules
Single responsibility?Module does one thing wellModule handles multiple unrelated concerns
Clear boundaries?Well-defined public APIInternal details exposed everywhere

Boundary Violations

Look for:

  • Code that should be in a different module
  • Module doing too many things
  • Missing module that should exist
  • Duplicate functionality across modules

Report Format

### Module Boundary Analysis

**Proposed location:** `src/module_name/`

**Assessment:** [Appropriate / Needs Discussion / Wrong Location]

**Findings:**
- [Finding 1]
- [Finding 2]

**Recommendation:** [Where code should go and why]

Phase 3: Analyze Dependencies

Dependency Direction

Good: High-level → Low-level
      UI → Business Logic → Data Access

Bad:  Low-level → High-level (inverted)
      Data Access → Business Logic

Check for Issues

IssueHow to DetectImpact
Circular dependencyA → B → C → ABuild issues, tight coupling
Wrong directionCore depends on featureCore becomes unstable
Missing abstractionConcrete class dependencyHard to test, rigid
Over-couplingModule depends on 10+ othersFragile, hard to change

Dependency Analysis Commands

# For C++ - find includes from changed files
grep -r "#include" <changed_files> | grep -v "test"

# For Python - find imports
grep -r "^import\|^from" <changed_files>

# Visualize with existing tools if available
# cmake --graphviz=deps.dot build/

Report Format

### Dependency Analysis

**New dependencies introduced:**
- `module_a` → `module_b` (via `InterfaceX`)
- `module_a` → `external_lib`

**Dependency direction:** [Correct / Inverted / Needs Abstraction]

**Circular dependencies:** [None found / Found: A → B → A]

**Coupling assessment:** [Low / Medium / High]

**Concerns:**
- [Concern 1]

**Recommendations:**
- [How to fix dependency issues]

Phase 4: Assess Testability

Testability Criteria

CriterionTestableNot Testable
DependenciesInjected via constructor/interfaceHard-coded, global state
Side effectsIsolated, controllableFile I/O, network in core logic
StateExplicit, observableHidden, implicit
InterfacesAbstract, mockableConcrete classes only

Questions to Answer

  1. Can this be unit tested in isolation?
    • Are dependencies injectable?
    • Can we mock collaborators?
  2. What's the mocking complexity?
    • How many mocks needed?
    • Are mocks simple or complex?
  3. Are there test-hostile patterns?
    • Singletons?
    • Static methods with side effects?
    • Global state?

Report Format

### Testability Assessment

**Can be unit tested in isolation:** [Yes / Partially / No]

**Dependencies:**
| Dependency | Injectable? | Mockable? |
|------------|-------------|-----------|
| `DatabaseClient` | Yes (constructor) | Yes (interface) |
| `Logger` | No (global) | No |

**Mocking complexity:** [Low / Medium / High]
- Mocks needed: [count]
- Complex mocks: [list]

**Test-hostile patterns found:**
- [Pattern and location]

**Recommendations:**
- [How to improve testability]

Phase 5: Simplicity Check

Over-Engineering Signals

SignalExample
Premature abstractionInterface with single implementation, no plans for more
Unnecessary indirectionFactory that creates one type, never extended
Speculative generality"We might need this later" code
Gold platingFeatures beyond requirements
Pattern overuseDesign pattern where simple code works

Questions to Ask

  1. What's the simplest solution that works?
    • Can this be a function instead of a class?
    • Can this be one class instead of three?
  2. Is the abstraction earning its keep?
    • Does the interface have multiple implementations?
    • Will it realistically be extended?
  3. YAGNI check
    • Is this solving a current problem or a hypothetical one?
    • What's the cost of adding this later if needed?

Simpler Alternatives

For each abstraction/pattern, consider:

CurrentAlternativeWhen to Prefer Alternative
Abstract factorySimple factory functionSingle product family
Strategy patternSwitch statement2-3 strategies, won't grow
Observer patternDirect callbackSingle observer
Dependency injectionDirect instantiationLeaf classes, no testing need

Report Format

### Simplicity Check

**Over-engineering concerns:**
- [Concern 1: what and why]
- [Concern 2: what and why]

**Simpler alternatives:**

| Current Approach | Simpler Alternative | Recommendation |
|------------------|---------------------|----------------|
| [What's proposed] | [Simpler option] | [Keep / Simplify] |

**YAGNI violations:**
- [Code that solves hypothetical problems]

**Verdict:** [Appropriate complexity / Over-engineered / Under-engineered]

Phase 6: Generate Report

Full Architecture Review Report

# Architecture Review

## Summary

**Scope:** [PR #X / Feature Y planning]

**Verdict:** [Approve / Concerns / Needs Rework]

**Key findings:**
- [1-3 bullet summary]

---

## 1. Existing Architecture Context

[Summary from Explore agent]

- **Relevant modules:** [list]
- **Key interfaces:** [list]
- **Patterns used:** [list]

---

## 2. Module Boundaries

**Assessment:** [Appropriate / Needs Discussion / Wrong Location]

[Details from Phase 2]

---

## 3. Dependencies

**Assessment:** [Clean / Minor Issues / Major Issues]

[Details from Phase 3]

---

## 4. Testability

**Assessment:** [Good / Acceptable / Poor]

[Details from Phase 4]

---

## 5. Simplicity

**Assessment:** [Appropriate / Over-engineered / Under-engineered]

[Details from Phase 5]

---

## Recommendations

### Must Address (Blocking)

1. [Critical architectural issue]

### Should Address (Non-blocking)

1. [Important improvement]

### Consider (Optional)

1. [Nice-to-have suggestion]

---

## Questions for Author

- [Clarifying questions about design decisions]

Phase 7: Update Architecture Memory

After completing analysis, update your memory:

# Architecture Memory

## Project: [project name]
Last updated: [date]

## Module Map
<!-- List all discovered modules and their responsibilities -->

| Module | Responsibility | Key Files |
|--------|----------------|-----------|
| src/core/ | Core business logic | core.cpp, engine.cpp |
| src/api/ | External API layer | handler.cpp, router.cpp |

## Key Interfaces
<!-- Important abstractions that define boundaries -->

- `IProcessor` - Main processing interface (src/core/processor.h)
- `IStorage` - Storage abstraction (src/storage/storage.h)

## Dependency Patterns
<!-- How modules connect to each other -->

api/ → core/ → storage/ ↘ utils/


## Architectural Decisions
<!-- Design choices and their rationale -->

- **Why X instead of Y**: [reason]
- **Pattern used for Z**: [pattern and why]

## Known Issues
<!-- Architectural debt or areas needing improvement -->

- Circular dependency between X and Y
- Core module is getting too large

Memory update rules:

  1. Only add confirmed patterns (not speculation)
  2. Update existing entries if they change
  3. Remove outdated information
  4. Keep memory concise and useful

Integration with Other Skills

From pr-review

pr-review detects architectural changes:
  → Invoke architecture-analyze
  → Include architecture report in PR review
  → Architectural issues become "Must Fix" items
  → Memory is updated with new architectural knowledge

From planning-feature

planning-feature validates design:
  → Invoke architecture-analyze with proposed design
  → Catch issues before coding starts
  → Adjust plan based on findings
  → Memory helps understand existing architecture faster

Quick Architecture Checklist

For fast reviews, at minimum verify:

  • Code is in the appropriate module
  • No circular dependencies introduced
  • Dependencies go in the right direction (high → low level)
  • New code can be unit tested
  • No obvious over-engineering

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.