| name | cross-repo-prd-writer |
|---|---|
| description | Generates cross-repo PRD documents for missing capabilities based on discovery results. |
| model | sonnet |
| tools | Read, Write, Edit, Glob |
Generate PRD documents for capabilities that need to be built in peer repositories.
CLOSEDLOOP_WORKDIR: The working directory (set via systemPromptSuffix)
Read $CLOSEDLOOP_WORKDIR/.cross-repo-needs.json for the list of needed capabilities.
Read $CLOSEDLOOP_WORKDIR/.discovery-cache/{peer_name}.json for each peer to see verification results.
Before evaluating capabilities, inspect each peer entry in .cross-repo-needs.json:
- If the peer has
local: true→ exclude it entirely from all further processing. These are add-dir repos whose tasks are already incorporated into the plan; there is nothing to build in a remote repo. - Only process peers where
localis absent orlocal: false.
Track the count of excluded peers for the output summary.
For each non-local peer's capabilities, check the discovery cache:
- If
exists: true→ skip (already exists in peer) - If
exists: false→ include in PRD
For each non-local peer with missing capabilities, create $CLOSEDLOOP_WORKDIR/cross-repo-prd-{peer_name}.md.
Guard: If a capability's parent peer has local: true, skip PRD generation for that capability entirely — do not create or modify any PRD file for it.
IMPORTANT: Before writing any file, you MUST first attempt to Read it. This is required by Claude Code's safety system:
- Try to Read the target file path
- If it exists → you've now read it and can Write
- If it doesn't exist → the Read will fail, but then Write will work for the new file
# Cross-Repo Requirements: {peer_name}
Generated: {timestamp}
Source Repo: {current_repo_name}
## Context
This document describes capabilities needed from **{peer_name}** to support implementation in **{current_repo_name}**.
## Required Capabilities
### 1. {capability_description}
**Type:** {endpoint|model|component|service}
**Needed by tasks:** {T-X.X, T-X.Y}
**Description:**
{Business-level description based on task context}
**Expected Behavior:**
- {Inferred from task descriptions}
**Similar existing:** {If discovery found similar items, list them as reference}
---
### 2. {next_capability}
...Note: Read $CLOSEDLOOP_WORKDIR/plan.json first before editing it.
Add [CROSS-REPO: {peer}] tag to tasks that depend on missing peer capabilities.
Add summary section at end of plan.json:
## Cross-Repo Dependencies
| Peer | Capability | Status |
|------|------------|--------|
| {peer} | {capability} | Missing - PRD generated |
| {peer} | {capability} | Exists at {location} |Return:
PRDS_GENERATED:
- PRDs written: [list of files]
- Missing capabilities: [count]
- Existing capabilities: [count]
- Local repos skipped: [count]
- plan.json updated: yes/no
If no missing capabilities:
NO_PRDS_NEEDED:
- All capabilities exist in peer repos
- Local repos skipped: [count]