diff --git a/CLAUDE.md b/CLAUDE.md index dd57f97..02794af 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -49,3 +49,40 @@ When modifying this repo: - Skills should be self-contained instructions that work without user interaction where possible - Agents should encode domain knowledge that would take multiple files to discover, not generic advice - Keep specialist agents in `agents/example-specialists/` to separate them from the generic set + + +## CodeGraph + +CodeGraph builds a semantic knowledge graph of codebases for faster, smarter code exploration. + +### If `.codegraph/` exists in the project + +**Use codegraph tools for faster exploration.** These tools provide instant lookups via the code graph instead of scanning files: + +| Tool | Use For | +|------|---------| +| `codegraph_search` | Find symbols by name (functions, classes, types) | +| `codegraph_context` | Get relevant code context for a task | +| `codegraph_callers` | Find what calls a function | +| `codegraph_callees` | Find what a function calls | +| `codegraph_impact` | See what's affected by changing a symbol | +| `codegraph_node` | Get details + source code for a symbol | + +**When spawning Explore agents in a codegraph-enabled project:** + +Tell the Explore agent to use codegraph tools for faster exploration. + +**For quick lookups in the main session:** +- Use `codegraph_search` instead of grep for finding symbols +- Use `codegraph_callers`/`codegraph_callees` to trace code flow +- Use `codegraph_impact` before making changes to see what's affected + +### If `.codegraph/` does NOT exist + +At the start of a session, ask the user if they'd like to initialize CodeGraph: + +"I notice this project doesn't have CodeGraph initialized. Would you like me to run `codegraph init -i` to build a code knowledge graph?" + +# graphify +- **graphify** (`~/.claude/skills/graphify/SKILL.md`) - any input to knowledge graph. Trigger: `/graphify` +When the user types `/graphify`, invoke the Skill tool with `skill: "graphify"` before doing anything else. diff --git a/skills/figma-driven-development/SKILL.md b/skills/figma-driven-development/SKILL.md new file mode 100644 index 0000000..6a96681 --- /dev/null +++ b/skills/figma-driven-development/SKILL.md @@ -0,0 +1,528 @@ +--- +name: figma-driven-development +description: Use when implementing UI from a Figma link. Required before writing any code when a Figma URL is provided. Also use when auditing an existing implementation for Figma fidelity. +--- + +# Figma-Driven Development + +Two modes: **Build** (Phases 1–6) and **Audit** (Phase 7). + +## Phase 1: Discover Figma Tools + +``` +ToolSearch("figma") +ToolSearch("select:mcp__claude_ai_Figma__get_metadata,mcp__claude_ai_Figma__get_design_context,mcp__claude_ai_Figma__get_screenshot") +``` + +If ToolSearch returns nothing: ask the user to connect Figma via claude.ai settings (`/mcp`) and restart. Do not implement from memory or screenshots without Figma access. + +**Tools:** +- `get_metadata` — XML structural tree (node IDs, names, sizes). Always call via subagent — root responses exceed context limits predictably. +- `get_design_context` — Reference code + screenshot + design values. Use when exact values are needed. +- `get_screenshot` — Visual render of a node. Use first — it's cheap. Escalate to `get_design_context` only to resolve discrepancies. + +## Phase 2: Parse the URL + +``` +https://www.figma.com/design/sHPq6WL754484sETatkL51/Name?node-id=9936-6 + ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ + fileKey nodeId (convert - to :) +``` + +Use the URL's `node-id` directly — it's the designer's intended frame. Never start from `0:1` (page root) — it returns the entire file and exceeds token limits. + +## Phase 3: Check for Existing Catalogue + +Catalogue index lives at `.figma/[fileKey].md`. Section files live at `.figma/[fileKey]/[section-slug].md`. Shared styles live at `.figma/[fileKey]/shared-styles.md`. + +- **Index exists + section present** → Phase 5 (build) or Phase 7 (audit) +- **Index exists + section missing** → Check for naming mismatch first. Then `get_screenshot(fileKey, rootNodeId)` to visually search. If still not found, ask the user for the specific node URL — do not guess. +- **Not exists** → Phase 4 + +## Phase 4: Build the Catalogue + +The catalogue is split into three file types so each subagent loads only what it needs: + +| File | Purpose | Who reads it | +|------|---------|--------------| +| `.figma/[fileKey].md` | Index: section list, node IDs, slugs, one-line descriptions | Every agent at the start | +| `.figma/[fileKey]/shared-styles.md` | CSS tokens, typography scale, shared spacing | Every implementation agent | +| `.figma/[fileKey]/[section-slug].md` | Full detail for one section: layout, colours, copy, assets | Only the agent implementing/auditing that section | + +### 4a. Fetch root metadata via subagent + +Always route `get_metadata` through a subagent — root frames for full pages predictably exceed context. Copy the exact file path from the tool result verbatim (UUID paths are easy to mistype). + +Subagent prompt: +> "File at **[exact path]** is JSON `[{type, text}]` where text is XML. Using jq or python3 (NOT Read tool): (1) root node name, type, width, height; (2) markdown table of ALL direct children: name | id | type | width | height. Return markdown only." + +The XML `name` attribute is the authoritative section name. If frames are generically named (e.g. `Frame 168…`), screenshot each child before writing the catalogue and name from visual content. + +### 4b. Screenshot all sections in parallel + +``` +get_screenshot(fileKey, sectionNodeId) — one per section, all at once +``` + +A full-page overview is too small to read — screenshot sections individually. + +### 4c. Write the catalogue index + +Save to `.figma/[fileKey].md`. This file must stay small — it is loaded into every agent's context. No style values, no copy, no code blocks here. + +```markdown +# Figma Catalogue — [File Name] +File key: [key] +Root node: `[nodeId]` ("[name]" — [width]×[height]px) +Catalogued: [date] + +Shared styles: `.figma/[fileKey]/shared-styles.md` + +## Sections + +| Section | Node ID | Size | Slug | Description | +|---------|---------|------|------|-------------| +| Hero | `9936:51` | 1440×803px | `hero` | Full-width hero with gradient background, heading, subheading, two CTAs, and hero illustration | +| Features | `9936:102` | 1440×960px | `features` | Three-column feature grid with icon cards | +| Pricing | `9936:188` | 1440×720px | `pricing` | Two-tier pricing cards with CTA buttons | + +## DRY Opportunities +- **[Pattern]**: Appears in [Section A] (`hero`), [Section B] (`features`) — candidate for `` or `.class` +``` + +### 4d. Write the shared styles file + +Save to `.figma/[fileKey]/shared-styles.md`. Include every value that appears in two or more sections. Values observed only from screenshots are flagged `[confirm]` — verify via `get_design_context` before use. + +```markdown +# Shared Styles — [File Name] +File key: [key] + +> Values marked `[confirm]` were observed from screenshots — verify exact values via get_design_context before use. + +## Colours +```css +--color-bg-primary: #0F0F1A; /* Page background */ +--color-bg-card: rgba(255,255,255,0.04); /* Card surface */ +--color-accent-start: #6C63FF; /* Gradient start [confirm] */ +--color-accent-end: #48CAE4; /* Gradient end [confirm] */ +--color-text-primary: #FFFFFF; +--color-text-secondary: #8B8BA7; +--color-border: rgba(255,255,255,0.08); +``` + +## Typography +```css +--font-family: 'Inter', sans-serif; +--text-xs: 12px / 16px; +--text-sm: 14px / 20px; +--text-base: 16px / 24px; +--text-lg: 20px / 28px; +--text-2xl: 24px / 32px; +--text-4xl: 36px / 44px; +--text-5xl: 48px / 56px; +``` + +## Spacing +```css +--section-padding-y: 80px; +--section-padding-x: 120px; +--card-padding: 32px; +--card-gap: 24px; +--card-radius: 16px; +``` +``` + +### 4e. Write each section file + +**Write ALL section files before fetching `get_design_context` for any section.** Screenshots from 4b are enough to write the stub — design context is fetched later, per-section, during Phase 5. If you fetch design context before the section files are on disk, you will rationalise skipping the write ("I already have the values in context") and the catalogue will be incomplete. + +Save to `.figma/[fileKey]/[section-slug].md`. One file per section. Include all concrete detail — layout code, typography values, colours, copy, assets, component mappings. An implementer should be able to start without re-fetching Figma. + +```markdown +# [Section Name] — [File Name] +File key: [key] +Node ID: `9936:51` +Size: 1440×803px +Slug: `hero` + +See shared styles: `shared-styles.md` + +## Complexity +**Score: [1–3]** — [Simple / Moderate / Complex] + +| Factor | Assessment | +|--------|------------| +| Layout complexity | [e.g. Single-column text — low] | +| Visual effects | [e.g. Two gradients, one with opacity overlay — medium] | +| Assets | [e.g. One SVG illustration — low] | +| Interactive states | [e.g. Three button variants with transitions — medium] | +| Responsive variants | [e.g. Three breakpoints with layout changes — medium] | +| Data / charts | [e.g. None — low] | +| Overlapping / absolute elements | [e.g. Decorative blobs positioned with negative insets — high] | + +**Error likelihood: [1–3]** — [Low / Medium / High] + +Key risks on first pass: +- [e.g. Gradient direction is subtle — easy to get wrong from screenshot alone] +- [e.g. Illustration size uses absolute px that collapses at tablet — confirm parent has explicit width] +- [e.g. CTA hover state not visible in static design — requires prototype inspection] + +> Complexity score drives the number of QA passes at the visual gate (1 pass / 2 passes / 3 passes). Error likelihood is a signal to the implementer about where to spend extra care. + +## Layout +```css +/* Outer wrapper */ +display: flex; +flex-direction: column; +align-items: center; +padding: 80px 120px; +gap: 48px; +max-width: 1440px; +``` + +## Typography +| Role | Font | Size | Weight | Line-height | Colour | +|------|------|------|--------|-------------|--------| +| Heading | Inter | 48px | 700 | 56px | #FFFFFF | +| Subheading | Inter | 20px | 400 | 28px | #8B8BA7 | +| CTA label | Inter | 16px | 600 | 24px | #FFFFFF | + +## Colours +| Token | Hex / gradient | Usage | +|-------|---------------|-------| +| Background | `linear-gradient(180deg, #1A0F3C 0%, #0F0F1A 100%)` | Section background [confirm] | +| CTA button | `linear-gradient(135deg, #6C63FF 0%, #48CAE4 100%)` | Primary button fill | +| Border | `rgba(255,255,255,0.08)` | Card border | + +## Spacing & Sizing +| Element | Value | +|---------|-------| +| Section padding (vertical) | `80px` | +| Section padding (horizontal) | `120px` | +| CTA gap | `16px` | +| Illustration width | `560px` | + +## Component Mapping +| Figma layer | Codebase component | Notes | +|-------------|--------------------|-------| +| `Button/Primary` | `