.agents/commands/comet/share-diagram.md
Command: cursor share-diagram
Analyze the current branch's diff and Jira ticket context, then generate a self-contained HTML architecture diagram at {MAIN_REPO_ROOT}/diagrams/opik-{TICKET_NUMBER}-diagram.html.
gh preferred, GitHub MCP fallback), re-analyzes the current branch diff and Jira context, then generates a fresh diagram.This workflow will:
diagram-generation skilldiagrams/ folder (gitignored, local artifact) — even when running inside a worktree, so the diagram survives worktree removalOPIK-4501flow, architecture, files, decisions, or all (default: all)If unavailable: warn but continue — diagram can be generated from code diff alone without Jira context.
gh is installed and authenticated (gh auth status)gh is unavailable or unauthenticated, test GitHub MCP availability by fetching repository info for comet-ml/opik.
If both are unavailable: warn but continue — diagram can be generated from local git diff alone.
MAIN_REPO_ROOT="$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")". This returns the main worktree root whether we're currently in the main checkout or in a linked worktree under .claude/worktrees/. All diagram output goes under ${MAIN_REPO_ROOT}/diagrams/ so the files outlive any temporary worktree.${MAIN_REPO_ROOT}/diagrams/ directory exists: Create if missing.OPIK-<number> from current branch (format: <username>/OPIK-<number>-<description>)main, NA branches like user/NA-some-task, or other non-standard formats): Check if a ticket number was provided as input. If not, ask the user for one.gh pr view --json number,title,url (preferred) or GitHub MCP to find an open PR for the current branch on comet-ml/opik
gh pr diff or GitHub MCP PR diff (preferred — includes review context)git diff main...HEAD for local changesBased on the changes, determine which sections to include:
| Change Type | Sections |
|---|---|
| New API endpoint | Request flow, files changed, design decisions |
| Bug fix | Problem/solution banners, before/after flow, safety guards |
| New feature | Data flow, architecture tree, files changed, design decisions |
| Refactor | Before/after architecture, files changed |
| Database migration | Storage diagram, data flow, migration notes |
| Cross-component | Full flow (API → Service → DAO → Storage), files by layer |
Always include Files Changed section. Include at most 4 sections total.
diagram-generation skill: Use the style guide and template from .agents/skills/diagram-generation/OPIK-{TICKET} — {Jira Title}<b> for component names inside boxes for secondary details in boxes.code spans for inline code references.note for supplementary explanations below flows${MAIN_REPO_ROOT}/diagrams/opik-{TICKET_NUMBER}-diagram.html — always under the main repo root, even when the session is running inside a worktree. This keeps the diagram accessible after the worktree is removed.${MAIN_REPO_ROOT}/diagrams/ directory if it doesn't existRender the diagram to PNG and display it inline in chat.
Note: Playwright MCP blocks file:// URLs, so serve the HTML over a local HTTP server.
python3 -m http.server 8787 --bind 127.0.0.1 in the ${MAIN_REPO_ROOT}/diagrams/ directory (run in background)browser_navigate to http://localhost:8787/opik-{TICKET_NUMBER}-diagram.htmlbrowser_evaluate with document.querySelector('.copy-btn').style.display = 'none' — prevents the fixed-position button from appearing in the screenshotbrowser_snapshot to get the element ref for #diagrambrowser_take_screenshot targeting the #diagram element ref
${MAIN_REPO_ROOT}/diagrams/opik-{TICKET_NUMBER}-diagram.pngdiagrams/ folder (not the worktree's)browser_close, then kill the HTTP server processRead tool on the PNG — it renders as an image inline in the chatIf Playwright MCP is not available, skip this step and fall back to showing the HTML file path.
[diagrams/opik-{TICKET}-diagram.html](${MAIN_REPO_ROOT}/diagrams/opik-{TICKET}-diagram.html)). Absolute paths ensure the link is clickable regardless of which folder the IDE has open as its workspace — important when the session is running inside a worktree while the user has the main repo open in VSCode.gh not installed or unauthenticated: Fall back to GitHub MCPgit diff main...HEADgit diff main...HEADmain with no ticket: Prompt for ticket numberThe command is successful when:
${MAIN_REPO_ROOT}/diagrams/opik-{TICKET_NUMBER}-diagram.html/diagrams/ folder is gitignoreddiagrams/ folder. When the session runs inside a worktree under .claude/worktrees/, the command resolves MAIN_REPO_ROOT via git rev-parse --git-common-dir so the file lands in the shared diagrams/ folder and survives worktree removal..agents/skills/diagram-generation/ (shared skill)End Command