figma-code-agent 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -0
- package/bin/install.js +328 -0
- package/knowledge/README.md +62 -0
- package/knowledge/css-strategy.md +973 -0
- package/knowledge/design-to-code-assets.md +855 -0
- package/knowledge/design-to-code-layout.md +929 -0
- package/knowledge/design-to-code-semantic.md +1085 -0
- package/knowledge/design-to-code-typography.md +1003 -0
- package/knowledge/design-to-code-visual.md +1145 -0
- package/knowledge/design-tokens-variables.md +1261 -0
- package/knowledge/design-tokens.md +960 -0
- package/knowledge/figma-api-devmode.md +894 -0
- package/knowledge/figma-api-plugin.md +920 -0
- package/knowledge/figma-api-rest.md +742 -0
- package/knowledge/figma-api-variables.md +848 -0
- package/knowledge/figma-api-webhooks.md +876 -0
- package/knowledge/payload-blocks.md +1184 -0
- package/knowledge/payload-figma-mapping.md +1210 -0
- package/knowledge/payload-visual-builder.md +1004 -0
- package/knowledge/plugin-architecture.md +1176 -0
- package/knowledge/plugin-best-practices.md +1206 -0
- package/knowledge/plugin-codegen.md +1313 -0
- package/package.json +31 -0
- package/skills/README.md +103 -0
- package/skills/audit-plugin/SKILL.md +244 -0
- package/skills/build-codegen-plugin/SKILL.md +279 -0
- package/skills/build-importer/SKILL.md +320 -0
- package/skills/build-plugin/SKILL.md +199 -0
- package/skills/build-token-pipeline/SKILL.md +363 -0
- package/skills/ref-html/SKILL.md +290 -0
- package/skills/ref-layout/SKILL.md +150 -0
- package/skills/ref-payload-block/SKILL.md +415 -0
- package/skills/ref-react/SKILL.md +222 -0
- package/skills/ref-tokens/SKILL.md +347 -0
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Figma Agent
|
|
2
|
+
|
|
3
|
+
A Claude Code plugin that provides expert-level Figma development knowledge through 19 knowledge modules and 10 invokable skills.
|
|
4
|
+
|
|
5
|
+
## What It Does
|
|
6
|
+
|
|
7
|
+
Figma Agent is a **developer expert tool** that helps you build software integrating with Figma. It encodes production-proven patterns for:
|
|
8
|
+
|
|
9
|
+
- **Plugin development** — Architecture, IPC, data flow, error handling, performance, caching, async patterns, testing
|
|
10
|
+
- **Codegen plugins** — Dev Mode integration, 3-second timeout strategy, preference system, language routing
|
|
11
|
+
- **Import pipelines** — REST API fetching, node traversal, platform-specific transformation, asset handling
|
|
12
|
+
- **Token synchronization** — Variables API, alias resolution, mode classification, multi-format rendering
|
|
13
|
+
- **Design-to-code** — Auto Layout to Flexbox, visual properties, typography, assets, semantic HTML
|
|
14
|
+
- **CMS integration** — PayloadCMS block mapping, field factories, container nesting, visual builder
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
### npx (recommended)
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Install globally — available in all projects
|
|
22
|
+
npx figma-code-agent
|
|
23
|
+
|
|
24
|
+
# Install to current project only
|
|
25
|
+
npx figma-code-agent --local
|
|
26
|
+
|
|
27
|
+
# Remove installed files
|
|
28
|
+
npx figma-code-agent --uninstall
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Plugin mode (for development)
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Load directly when starting Claude Code
|
|
35
|
+
claude --plugin-dir /path/to/figma-code-agent
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Manual (requires clone)
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Symlink all skills to ~/.claude/skills/
|
|
42
|
+
./install.sh
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Skills
|
|
46
|
+
|
|
47
|
+
After installation, invoke skills directly in Claude Code:
|
|
48
|
+
|
|
49
|
+
### Tier 1: Developer Workflow
|
|
50
|
+
|
|
51
|
+
| Skill | What It Does |
|
|
52
|
+
|-------|-------------|
|
|
53
|
+
| `/fca:build-plugin` | Build a Figma plugin from scratch or enhance an existing one |
|
|
54
|
+
| `/fca:build-codegen-plugin` | Build a Dev Mode codegen plugin that generates code from designs |
|
|
55
|
+
| `/fca:build-importer` | Build a service that fetches Figma designs into a CMS or React app |
|
|
56
|
+
| `/fca:build-token-pipeline` | Build a pipeline that syncs Figma design tokens to code |
|
|
57
|
+
|
|
58
|
+
### Tier 2: Reference / Validation
|
|
59
|
+
|
|
60
|
+
| Skill | What It Does |
|
|
61
|
+
|-------|-------------|
|
|
62
|
+
| `/fca:ref-layout` | Interpret Figma Auto Layout and generate CSS Flexbox |
|
|
63
|
+
| `/fca:ref-react` | Generate a React/TSX component from Figma node data |
|
|
64
|
+
| `/fca:ref-html` | Generate semantic HTML + CSS from Figma node data |
|
|
65
|
+
| `/fca:ref-tokens` | Extract design tokens into CSS variables + Tailwind config |
|
|
66
|
+
| `/fca:ref-payload-block` | Map a Figma component to a PayloadCMS block |
|
|
67
|
+
|
|
68
|
+
### Tier 3: Audit
|
|
69
|
+
|
|
70
|
+
| Skill | What It Does |
|
|
71
|
+
|-------|-------------|
|
|
72
|
+
| `/fca:audit-plugin` | Audit a Figma plugin against production best practices |
|
|
73
|
+
|
|
74
|
+
### Example
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
/fca:build-plugin I want to build a plugin that exports frames as React components
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Tier 1 skills follow a 4-phase process: **Assess** the project → **Recommend** architecture → **Implement** code → **Validate** against best practices. Tier 2 skills follow a structured step-by-step process for direct code generation from Figma data.
|
|
81
|
+
|
|
82
|
+
## Knowledge Modules
|
|
83
|
+
|
|
84
|
+
19 modules organized by domain, usable as standalone `@file` references in any project:
|
|
85
|
+
|
|
86
|
+
| Domain | Modules | Topics |
|
|
87
|
+
|--------|---------|--------|
|
|
88
|
+
| Figma API | 5 | REST API, Plugin API, Variables, Webhooks, Dev Mode |
|
|
89
|
+
| Design-to-Code | 5 | Layout, Visual, Typography, Assets, Semantic HTML |
|
|
90
|
+
| CSS & Tokens | 3 | Three-layer CSS, Token extraction, Variables-to-CSS bridge |
|
|
91
|
+
| PayloadCMS | 3 | Block system, Figma-to-block mapping, Visual builder |
|
|
92
|
+
| Plugin Dev | 3 | Architecture, Codegen plugins, Best practices |
|
|
93
|
+
|
|
94
|
+
Reference any module directly in your project:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
@/path/to/figma-code-agent/knowledge/design-to-code-layout.md
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Project Structure
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
figma-code-agent/
|
|
104
|
+
bin/
|
|
105
|
+
install.js # npx installer (copies files to ~/.claude/)
|
|
106
|
+
.claude-plugin/
|
|
107
|
+
plugin.json # Claude Code plugin manifest
|
|
108
|
+
skills/
|
|
109
|
+
build-plugin/ # Build a Figma plugin
|
|
110
|
+
build-codegen-plugin/ # Build a codegen plugin
|
|
111
|
+
build-importer/ # Build a Figma importer
|
|
112
|
+
build-token-pipeline/ # Build a token sync pipeline
|
|
113
|
+
ref-layout/ # Reference: Auto Layout -> Flexbox
|
|
114
|
+
ref-react/ # Reference: Figma -> React/TSX
|
|
115
|
+
ref-html/ # Reference: Figma -> HTML + CSS
|
|
116
|
+
ref-tokens/ # Reference: Figma -> CSS variables + Tailwind
|
|
117
|
+
ref-payload-block/ # Reference: Figma -> PayloadCMS block
|
|
118
|
+
audit-plugin/ # Plugin quality audit
|
|
119
|
+
knowledge/ # 19 standalone knowledge modules
|
|
120
|
+
package.json # npm package for npx installation
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## CSS Strategy
|
|
124
|
+
|
|
125
|
+
Generated CSS follows a three-layer architecture:
|
|
126
|
+
|
|
127
|
+
1. **Tailwind** — Layout structure (flexbox, spacing, sizing)
|
|
128
|
+
2. **CSS Custom Properties** — Design tokens (colors, typography, radii, shadows)
|
|
129
|
+
3. **CSS Modules** — Visual skin (component-specific styles)
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
MIT
|
package/bin/install.js
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
const readline = require('readline');
|
|
9
|
+
|
|
10
|
+
// --- Constants ---
|
|
11
|
+
|
|
12
|
+
const PLUGIN_NAME = 'fca';
|
|
13
|
+
|
|
14
|
+
const SKILL_NAMES = [
|
|
15
|
+
// Tier 1: Developer workflow skills
|
|
16
|
+
'build-plugin',
|
|
17
|
+
'build-codegen-plugin',
|
|
18
|
+
'build-importer',
|
|
19
|
+
'build-token-pipeline',
|
|
20
|
+
// Tier 2: Reference/validation skills
|
|
21
|
+
'ref-layout',
|
|
22
|
+
'ref-react',
|
|
23
|
+
'ref-html',
|
|
24
|
+
'ref-tokens',
|
|
25
|
+
'ref-payload-block',
|
|
26
|
+
// Tier 3: Audit
|
|
27
|
+
'audit-plugin',
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const SKILL_DESCRIPTIONS = {
|
|
31
|
+
'build-plugin': 'Build a Figma plugin from scratch or enhance one',
|
|
32
|
+
'build-codegen-plugin': 'Build a Dev Mode codegen plugin',
|
|
33
|
+
'build-importer': 'Build a Figma-to-CMS/React importer service',
|
|
34
|
+
'build-token-pipeline': 'Build a Figma token sync pipeline',
|
|
35
|
+
'ref-layout': 'Reference: Interpret Auto Layout -> CSS Flexbox',
|
|
36
|
+
'ref-react': 'Reference: Generate React/TSX from Figma node',
|
|
37
|
+
'ref-html': 'Reference: Generate HTML + layered CSS',
|
|
38
|
+
'ref-tokens': 'Reference: Extract design tokens -> CSS vars + Tailwind',
|
|
39
|
+
'ref-payload-block': 'Reference: Map Figma component -> PayloadCMS block',
|
|
40
|
+
'audit-plugin': 'Audit plugin against best practices',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// --- Paths ---
|
|
44
|
+
|
|
45
|
+
const PKG_ROOT = path.resolve(__dirname, '..');
|
|
46
|
+
|
|
47
|
+
function getGlobalBase() {
|
|
48
|
+
return path.join(os.homedir(), '.claude');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getLocalBase() {
|
|
52
|
+
return path.join(process.cwd(), '.claude');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getTargets(base) {
|
|
56
|
+
return {
|
|
57
|
+
commands: path.join(base, 'commands', PLUGIN_NAME),
|
|
58
|
+
knowledge: path.join(base, PLUGIN_NAME, 'knowledge'),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getKnowledgeRefPath(base) {
|
|
63
|
+
// For global: @~/.claude/fca/knowledge/filename.md
|
|
64
|
+
// For local: @.claude/fca/knowledge/filename.md
|
|
65
|
+
const home = os.homedir();
|
|
66
|
+
if (base.startsWith(home)) {
|
|
67
|
+
return `~/.claude/${PLUGIN_NAME}/knowledge`;
|
|
68
|
+
}
|
|
69
|
+
return `.claude/${PLUGIN_NAME}/knowledge`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// --- File operations ---
|
|
73
|
+
|
|
74
|
+
function ensureDir(dir) {
|
|
75
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function getKnowledgeFiles() {
|
|
79
|
+
const knowledgeDir = path.join(PKG_ROOT, 'knowledge');
|
|
80
|
+
return fs.readdirSync(knowledgeDir)
|
|
81
|
+
.filter(f => f.endsWith('.md') && f !== 'README.md')
|
|
82
|
+
.sort();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function copyWithPathReplacement(src, dest, replacements) {
|
|
86
|
+
let content = fs.readFileSync(src, 'utf-8');
|
|
87
|
+
for (const [search, replace] of replacements) {
|
|
88
|
+
content = content.replaceAll(search, replace);
|
|
89
|
+
}
|
|
90
|
+
ensureDir(path.dirname(dest));
|
|
91
|
+
fs.writeFileSync(dest, content, 'utf-8');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// --- Install ---
|
|
95
|
+
|
|
96
|
+
function install(base) {
|
|
97
|
+
const targets = getTargets(base);
|
|
98
|
+
const knowledgeRefPath = getKnowledgeRefPath(base);
|
|
99
|
+
const replacements = [
|
|
100
|
+
['@knowledge/', `@${knowledgeRefPath}/`],
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
// Validate source files
|
|
104
|
+
console.log('Validating source files...');
|
|
105
|
+
let missing = 0;
|
|
106
|
+
|
|
107
|
+
for (const name of SKILL_NAMES) {
|
|
108
|
+
const src = path.join(PKG_ROOT, 'skills', name, 'SKILL.md');
|
|
109
|
+
if (!fs.existsSync(src)) {
|
|
110
|
+
console.log(` ERROR: Missing skill: skills/${name}/SKILL.md`);
|
|
111
|
+
missing++;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const knowledgeFiles = getKnowledgeFiles();
|
|
116
|
+
for (const file of knowledgeFiles) {
|
|
117
|
+
const src = path.join(PKG_ROOT, 'knowledge', file);
|
|
118
|
+
if (!fs.existsSync(src)) {
|
|
119
|
+
console.log(` ERROR: Missing knowledge file: knowledge/${file}`);
|
|
120
|
+
missing++;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (missing > 0) {
|
|
125
|
+
console.log(`\nAborting: ${missing} source file(s) missing.`);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
console.log(` ${SKILL_NAMES.length} skills + ${knowledgeFiles.length} knowledge files found.`);
|
|
129
|
+
console.log('');
|
|
130
|
+
|
|
131
|
+
// Copy skills as commands
|
|
132
|
+
console.log('Installing skills...');
|
|
133
|
+
let skillCount = 0;
|
|
134
|
+
for (const name of SKILL_NAMES) {
|
|
135
|
+
const src = path.join(PKG_ROOT, 'skills', name, 'SKILL.md');
|
|
136
|
+
const dest = path.join(targets.commands, `${name}.md`);
|
|
137
|
+
copyWithPathReplacement(src, dest, replacements);
|
|
138
|
+
console.log(` ${name}.md`);
|
|
139
|
+
skillCount++;
|
|
140
|
+
}
|
|
141
|
+
console.log('');
|
|
142
|
+
|
|
143
|
+
// Copy knowledge files
|
|
144
|
+
console.log('Installing knowledge modules...');
|
|
145
|
+
let knowledgeCount = 0;
|
|
146
|
+
for (const file of knowledgeFiles) {
|
|
147
|
+
const src = path.join(PKG_ROOT, 'knowledge', file);
|
|
148
|
+
const dest = path.join(targets.knowledge, file);
|
|
149
|
+
ensureDir(path.dirname(dest));
|
|
150
|
+
fs.copyFileSync(src, dest);
|
|
151
|
+
console.log(` ${file}`);
|
|
152
|
+
knowledgeCount++;
|
|
153
|
+
}
|
|
154
|
+
console.log('');
|
|
155
|
+
|
|
156
|
+
// Summary
|
|
157
|
+
const location = base === getGlobalBase() ? 'global (~/.claude/)' : `local (${path.relative(process.cwd(), base) || '.claude/'})`;
|
|
158
|
+
console.log(`Installed ${skillCount} skills + ${knowledgeCount} knowledge modules (${location})`);
|
|
159
|
+
console.log('');
|
|
160
|
+
console.log('Invoke skills in Claude Code:');
|
|
161
|
+
for (const name of SKILL_NAMES) {
|
|
162
|
+
const desc = SKILL_DESCRIPTIONS[name] || '';
|
|
163
|
+
console.log(` /fca:${name.padEnd(22)} ${desc}`);
|
|
164
|
+
}
|
|
165
|
+
console.log('');
|
|
166
|
+
console.log('Tip: Use /clear before invoking a skill for a fresh context window.');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// --- Uninstall ---
|
|
170
|
+
|
|
171
|
+
function uninstall(base) {
|
|
172
|
+
const targets = getTargets(base);
|
|
173
|
+
let removed = 0;
|
|
174
|
+
|
|
175
|
+
console.log('Uninstalling Figma Agent...');
|
|
176
|
+
console.log('');
|
|
177
|
+
|
|
178
|
+
// Remove command files
|
|
179
|
+
if (fs.existsSync(targets.commands)) {
|
|
180
|
+
const files = fs.readdirSync(targets.commands);
|
|
181
|
+
for (const file of files) {
|
|
182
|
+
fs.unlinkSync(path.join(targets.commands, file));
|
|
183
|
+
console.log(` Removed command: ${file}`);
|
|
184
|
+
removed++;
|
|
185
|
+
}
|
|
186
|
+
fs.rmSync(targets.commands, { recursive: true, force: true });
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Remove knowledge files
|
|
190
|
+
if (fs.existsSync(targets.knowledge)) {
|
|
191
|
+
const files = fs.readdirSync(targets.knowledge);
|
|
192
|
+
for (const file of files) {
|
|
193
|
+
fs.unlinkSync(path.join(targets.knowledge, file));
|
|
194
|
+
console.log(` Removed knowledge: ${file}`);
|
|
195
|
+
removed++;
|
|
196
|
+
}
|
|
197
|
+
fs.rmSync(targets.knowledge, { recursive: true, force: true });
|
|
198
|
+
|
|
199
|
+
// Remove parent fca directory if empty
|
|
200
|
+
const parentDir = path.dirname(targets.knowledge);
|
|
201
|
+
try {
|
|
202
|
+
const remaining = fs.readdirSync(parentDir);
|
|
203
|
+
if (remaining.length === 0) {
|
|
204
|
+
fs.rmdirSync(parentDir);
|
|
205
|
+
}
|
|
206
|
+
} catch {
|
|
207
|
+
// Ignore — parent may not exist or may not be empty
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
console.log('');
|
|
212
|
+
if (removed === 0) {
|
|
213
|
+
console.log('Nothing to remove — Figma Agent is not installed at this location.');
|
|
214
|
+
} else {
|
|
215
|
+
console.log(`Done. Removed ${removed} file(s).`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// --- Interactive prompt ---
|
|
220
|
+
|
|
221
|
+
function prompt(question, choices) {
|
|
222
|
+
return new Promise((resolve) => {
|
|
223
|
+
const rl = readline.createInterface({
|
|
224
|
+
input: process.stdin,
|
|
225
|
+
output: process.stdout,
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
console.log(question);
|
|
229
|
+
console.log('');
|
|
230
|
+
choices.forEach((choice, i) => {
|
|
231
|
+
console.log(` ${i + 1}) ${choice.label}`);
|
|
232
|
+
});
|
|
233
|
+
console.log('');
|
|
234
|
+
|
|
235
|
+
rl.question('Choose [1-' + choices.length + ']: ', (answer) => {
|
|
236
|
+
rl.close();
|
|
237
|
+
const idx = parseInt(answer, 10) - 1;
|
|
238
|
+
if (idx >= 0 && idx < choices.length) {
|
|
239
|
+
resolve(choices[idx].value);
|
|
240
|
+
} else {
|
|
241
|
+
console.log('Invalid choice. Defaulting to global install.');
|
|
242
|
+
resolve('global');
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// --- CLI ---
|
|
249
|
+
|
|
250
|
+
async function main() {
|
|
251
|
+
const args = process.argv.slice(2);
|
|
252
|
+
|
|
253
|
+
// Parse flags
|
|
254
|
+
let mode = null;
|
|
255
|
+
let isUninstall = false;
|
|
256
|
+
let showHelp = false;
|
|
257
|
+
|
|
258
|
+
for (const arg of args) {
|
|
259
|
+
switch (arg) {
|
|
260
|
+
case '--global':
|
|
261
|
+
case '-g':
|
|
262
|
+
mode = 'global';
|
|
263
|
+
break;
|
|
264
|
+
case '--local':
|
|
265
|
+
case '-l':
|
|
266
|
+
mode = 'local';
|
|
267
|
+
break;
|
|
268
|
+
case '--uninstall':
|
|
269
|
+
case '-u':
|
|
270
|
+
isUninstall = true;
|
|
271
|
+
break;
|
|
272
|
+
case '--help':
|
|
273
|
+
case '-h':
|
|
274
|
+
showHelp = true;
|
|
275
|
+
break;
|
|
276
|
+
default:
|
|
277
|
+
console.log(`Unknown option: ${arg}`);
|
|
278
|
+
showHelp = true;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (showHelp) {
|
|
284
|
+
console.log(`
|
|
285
|
+
Figma Agent — npx installer
|
|
286
|
+
|
|
287
|
+
Usage: npx figma-code-agent [OPTIONS]
|
|
288
|
+
|
|
289
|
+
Options:
|
|
290
|
+
--global, -g Install to ~/.claude/ (available in all projects)
|
|
291
|
+
--local, -l Install to .claude/ in current project
|
|
292
|
+
--uninstall, -u Remove installed files
|
|
293
|
+
--help, -h Show this help message
|
|
294
|
+
|
|
295
|
+
Examples:
|
|
296
|
+
npx figma-code-agent Interactive mode (choose global or local)
|
|
297
|
+
npx figma-code-agent --global Install globally to ~/.claude/
|
|
298
|
+
npx figma-code-agent --local Install to current project's .claude/
|
|
299
|
+
npx figma-code-agent --uninstall Remove from ~/.claude/ (default)
|
|
300
|
+
npx figma-code-agent --uninstall --local Remove from .claude/
|
|
301
|
+
`);
|
|
302
|
+
process.exit(0);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Handle uninstall
|
|
306
|
+
if (isUninstall) {
|
|
307
|
+
const base = mode === 'local' ? getLocalBase() : getGlobalBase();
|
|
308
|
+
uninstall(base);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// If no mode specified, prompt interactively
|
|
313
|
+
if (!mode) {
|
|
314
|
+
mode = await prompt('Where should Figma Agent be installed?', [
|
|
315
|
+
{ label: 'Global — ~/.claude/ (available in all projects)', value: 'global' },
|
|
316
|
+
{ label: 'Local — .claude/ (current project only)', value: 'local' },
|
|
317
|
+
]);
|
|
318
|
+
console.log('');
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const base = mode === 'local' ? getLocalBase() : getGlobalBase();
|
|
322
|
+
install(base);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
main().catch((err) => {
|
|
326
|
+
console.error('Error:', err.message);
|
|
327
|
+
process.exit(1);
|
|
328
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Knowledge Modules
|
|
2
|
+
|
|
3
|
+
Modular knowledge files optimized for Claude Code `@file` reference consumption. Each module is a self-contained reference document that can be @referenced independently.
|
|
4
|
+
|
|
5
|
+
## Naming Convention
|
|
6
|
+
|
|
7
|
+
Files follow `{domain}-{topic}.md` format:
|
|
8
|
+
- `figma-api-rest.md` -- Figma REST API reference
|
|
9
|
+
- `design-to-code-layout.md` -- Auto Layout to Flexbox mapping
|
|
10
|
+
- `css-strategy.md` -- Layered CSS approach documentation
|
|
11
|
+
|
|
12
|
+
## Module Structure
|
|
13
|
+
|
|
14
|
+
Each knowledge file follows this structure:
|
|
15
|
+
|
|
16
|
+
1. **Title** -- Clear module name
|
|
17
|
+
2. **Purpose** -- What knowledge this module contains
|
|
18
|
+
3. **When to Use** -- Scenarios where this module should be @referenced
|
|
19
|
+
4. **Content** -- The knowledge itself (rules, mappings, patterns, examples)
|
|
20
|
+
5. **Cross-References** -- Related modules to consult for full context
|
|
21
|
+
|
|
22
|
+
## Available Modules (19)
|
|
23
|
+
|
|
24
|
+
### Figma API (5 modules)
|
|
25
|
+
- `figma-api-rest.md` -- REST API endpoints, authentication, pagination, rate limits, node structure
|
|
26
|
+
- `figma-api-plugin.md` -- Plugin API sandbox model, SceneNode types, IPC patterns, manifest format
|
|
27
|
+
- `figma-api-variables.md` -- Variables API (collections, modes, bound variables, fallbacks)
|
|
28
|
+
- `figma-api-webhooks.md` -- Webhooks v2 format, event types, verification
|
|
29
|
+
- `figma-api-devmode.md` -- Dev Mode, codegen plugins, Dev Resources API
|
|
30
|
+
|
|
31
|
+
### Design-to-Code (5 modules)
|
|
32
|
+
- `design-to-code-layout.md` -- Auto Layout → Flexbox mapping (sizing modes, alignment, spacing)
|
|
33
|
+
- `design-to-code-visual.md` -- Visual property extraction (fills, strokes, effects, gradients)
|
|
34
|
+
- `design-to-code-typography.md` -- Text extraction (font mapping, line height, text styles)
|
|
35
|
+
- `design-to-code-assets.md` -- Asset management (vector containers, image dedup, SVG export)
|
|
36
|
+
- `design-to-code-semantic.md` -- Semantic HTML generation (element selection, ARIA, BEM naming)
|
|
37
|
+
|
|
38
|
+
### CSS Strategy & Design Tokens (3 modules)
|
|
39
|
+
- `css-strategy.md` -- Layered CSS approach (Tailwind + CSS Custom Properties + CSS Modules)
|
|
40
|
+
- `design-tokens.md` -- Token extraction (threshold-based promotion, CSS variable naming)
|
|
41
|
+
- `design-tokens-variables.md` -- Figma Variables deep dive (modes, fallback chains, scopes)
|
|
42
|
+
|
|
43
|
+
### PayloadCMS Integration (3 modules)
|
|
44
|
+
- `payload-blocks.md` -- Block system (config, fields, renderers, type generation, plugins)
|
|
45
|
+
- `payload-figma-mapping.md` -- Figma component → block mapping patterns
|
|
46
|
+
- `payload-visual-builder.md` -- Visual builder plugin architecture
|
|
47
|
+
|
|
48
|
+
### Plugin Development (3 modules)
|
|
49
|
+
- `plugin-architecture.md` -- Plugin sandbox model, IPC, @create-figma-plugin patterns
|
|
50
|
+
- `plugin-codegen.md` -- Codegen plugin patterns (Dev Mode integration)
|
|
51
|
+
- `plugin-best-practices.md` -- Production patterns for Figma plugins
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
Reference any module in your project's `CLAUDE.md` or inline:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
@/path/to/figma-code-agent/knowledge/figma-api-rest.md
|
|
59
|
+
@/path/to/figma-code-agent/knowledge/design-to-code-layout.md
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Skills in `skills/` automatically @reference the knowledge modules they depend on.
|