Annotate guidance

From juicesharp/rpiv-pi · View interactive version

Annotate guidance is an AI agent skill from the GitHub repository juicesharp/rpiv-pi. Generate architecture.md guidance files in .rpiv/guidance/ by analyzing architecture and patterns in parallel. Auto-detects architecture, proposes locations, and batch-writes compact documentation. Use for onboarding or improving AI assistant context.

How to use this skill

Skill file

Annotate Project

You are tasked with generating architecture guidance files for a brownfield project. You will map the project structure, auto-detect its architecture, analyze each architectural layer, and batch-write compact architecture.md files under .rpiv/guidance/ mirroring the project's directory structure.

Initial Setup:

Use the current working directory as the target project by default. If the user provides a specific directory path as an argument, use that instead.

Steps to follow:

  1. Read any directly mentioned files first:
  1. Pass 1 — Map the project (parallel agents):

Agent A — Project tree mapping:

Agent B — Architecture and conventions:

  1. Wait for Pass 1 and determine guidance targets:

Initial pass — identify top-level targets:

Decomposition pass — expand composite targets (ADD, never REPLACE):

```

## Proposed Guidance Locations

Architecture detected: [pattern name]

Files will be written to .rpiv/guidance/ mirroring the project structure.

### Folders that need architectural guidance:

### Folders to skip:

Does this look right? Should I add or remove any locations?

```

  1. Pass 2 — Analyze each layer (parallel analyzer agents):

For each target folder, spawn TWO agents:

Analyzer agent:

Pattern finder agent:

  1. Wait for Pass 2 and synthesize:
  1. Developer checkpoint — validate findings before drafting:

Present a per-folder findings summary, then ask grounded questions. This pulls domain knowledge that agents can't discover from code alone — deprecated patterns, undocumented conventions, migration-in-progress situations, or cross-layer rules that only the developer knows.

Findings summary — one block per target folder, 2-3 lines each:

```

## Findings Summary

### src/core/

Patterns: Repository base class, Entity base with soft-delete, Value Objects

Dependencies: Database layer (outbound), Services layer (inbound)

Workflows detected: "Add new entity" (5 steps), "Add new value object" (2 steps)

### src/services/

Patterns: Result<T> wrapping, Transaction scope per operation

Dependencies: Core (outbound), Controllers (inbound)

Workflows detected: "Add new service" (4 steps)

[etc.]

```

Then ask grounded questions — one at a time, waiting for the developer's answer before asking the next. Ask as many as the findings warrant — one per significant ambiguity or discovery gap. Use a ❓ Question: prefix. Each question must reference real findings and pull NEW information from the developer — not confirm what you already found, and not ask about cosmetic issues (typos, formatting) or absences the developer can't add context to.

Only ask questions whose answer would change what gets written in an architecture.md file. Focus on:

Example grounded questions:

CRITICAL: Ask ONE question at a time. Wait for the answer before asking the next. Lead with your most significant finding. The developer will redirect you if needed.

Choosing question format:

"❓ Question: Integration scanner found no background job registration for this area. Is that expected, or is there async processing I'm not seeing?"

Batching: When you have 2-4 independent questions (answers don't depend on each other), you MAY batch them in a single ask_user_question call. Keep dependent questions sequential.

Incorporate developer input:

Corrections ("that pattern is deprecated", "wrong — we use X"):

Missing conventions ("you missed the soft-delete convention", "all handlers must be idempotent"):

Migration context ("we're moving from X to Y", "old pattern in these files, new pattern in those"):

Scope adjustments ("skip that layer, it's being rewritten", "add src/shared/"):

Confirmations ("looks right", "yes that's correct"):

After incorporating all input, proceed to Step 7.

  1. Draft architecture.md content:
  1. Self-review pass — verify every drafted file before writing:

Walk through each drafted architecture.md and check every item below. Fix violations in-place before proceeding to writing.

Dependencies — for each listed dependency, ask: "does this library impose patterns, constraints, or conventions on the code?" If the answer is no (utility libraries like lodash, moment, xlsx, FontAwesome), remove it. Only frameworks and libraries that shape how you write code survive.

Module Structure — count top-level entries. If more than 7, group related directories on one line (e.g., guards/, interceptors/, pipes/ — cross-cutting plumbing). Target 4-7 entries.

Pattern sections — every pattern H2 must contain a fenced code block with an idiomatic example. If a section is prose-only or comment-only, either expand it with a real code example or replace the section with a one-line file reference (e.g., "see TradeDeskMapping.cs for the mapping pattern").

Root deduplication — for each root conditional block, verify it is NOT summarizing a layer that has its own subfolder architecture.md. If it is, remove the block. For cross-layer vertical-slice checklists, verify each step references the relevant subfolder file (e.g., "see .rpiv/guidance/X/architecture.md") rather than inlining the procedure.

Frontend/UI conditional coverage — for each frontend/UI layer, list every repeatable workflow the pattern-finder reported (components, services, pages/routes, directives, pipes, hooks, stores — whatever was detected). Then compare that list against the drafted <important if> conditional sections. Any workflow on the list without a matching conditional is a gap — draft and add the missing section before proceeding.

After fixing all violations, re-scan the corrected drafts to confirm every check passes. Only proceed to writing when all checks are clean. Present a brief summary of what was fixed:

```

## Self-review results

```

  1. Pass 3 — Write all architecture.md files:

```

## Architecture Guidance Files Created

| File | Lines | Description |

|------|-------|-------------|

| .rpiv/guidance/architecture.md | 45 | Root project overview |

| .rpiv/guidance/src/core/architecture.md | 78 | Core domain layer |

| .rpiv/guidance/src/services/architecture.md | 65 | Service layer |

| [etc.] | | |

Total: [N] files created/updated

Please review the files and let me know if you'd like any adjustments.

```

  1. Handle follow-up adjustments:

Root Architecture Template (compact):

Read the full template at templates/root-architecture.md.

Key principles:

Root Architecture Reference Examples

See examples/root-nodejs-monorepo.md (Node.js monorepo) and examples/root-dotnet-clean-arch.md (.NET Clean Architecture) for well-formed root architecture.md examples.

What makes these examples good:

Subfolder Architecture Template (max 100 lines):

Read the full template at templates/subfolder-architecture.md.

Key principles:

Reference Examples

See the following for well-formed subfolder architecture.md examples:

What makes these examples good:

Guidance Depth Rules:

CREATE architecture.md when:

SKIP architecture.md when:

Important notes:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.