{"id":25052,"library":"canicode","title":"CanICode","description":"CanICode v0.12.3 is a CLI and MCP server that lints Figma designs for AI code-generation readiness. It runs 16 deterministic rules (no AI cost) across 6 categories (Pixel Critical, Responsive, Code Quality, Token Management, Interaction, Semantic) and automatically fixes issues via Figma API, enabling a roundtrip workflow. Requires Node.js >=22. Differentiators: rule scores are ablation-validated with 94% pixel accuracy using 5× fewer tokens than raw JSON, and the calibration pipeline uses pixel-level comparison (visual-compare) against community fixtures. Supports both capture-only (gotchas) and write-to-Figma (roundtrip) modes. Released frequently (every few weeks) under active development.","status":"active","version":"0.12.3","language":"javascript","source_language":"en","source_url":"https://github.com/let-sunny/canicode","tags":["javascript","figma","design","analysis","cli","mcp","readiness","ai","typescript"],"install":[{"cmd":"npm install canicode","lang":"bash","label":"npm"},{"cmd":"yarn add canicode","lang":"bash","label":"yarn"},{"cmd":"pnpm add canicode","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used to interact with Figma REST API for reading and writing design data","package":"figma-api","optional":false}],"imports":[{"note":"ESM-only package; requires Node >=22. No default export in current API; prefer named CLI usage.","wrong":"const canicode = require('canicode')","symbol":"default","correct":"import canicode from 'canicode'"},{"note":"Named export for programmatic analysis. TypeScript types are bundled.","wrong":"import Analyzer from 'canicode/Analyzer'","symbol":"Analyzer","correct":"import { Analyzer } from 'canicode'"},{"note":"Named export for the roundtrip (write-to-Figma) workflow. Introduced in v0.11.0.","wrong":"import { Roundtrip } from 'canicode/roundtrip'","symbol":"Roundtrip","correct":"import { Roundtrip } from 'canicode'"}],"quickstart":{"code":"#!/usr/bin/env node\nimport { Analyzer } from 'canicode';\n\nconst figmaToken = process.env.FIGMA_TOKEN ?? '';\nconst fileKey = process.env.FIGMA_FILE_KEY ?? '';\n\nconst analyzer = new Analyzer({ token: figmaToken });\n\nasync function main() {\n  const result = await analyzer.analyzeFile(fileKey);\n  console.log('Overall grade:', result.grade);\n  console.log('Rule results:', JSON.stringify(result.rules, null, 2));\n  console.log('Gotchas:', result.gotchas);\n}\n\nmain().catch(console.error);\n","lang":"typescript","description":"Shows programmatic usage to analyze a Figma file and print grade, rule results, and gotchas."},"warnings":[{"fix":"Set FIGMA_TOKEN environment variable or use 'canicode init --token' to configure.","message":"v0.12.0 removed the '--api' flag from 'analyze' subcommand. Use 'FIGMA_TOKEN' env var or config file instead.","severity":"breaking","affected_versions":">=0.12.0"},{"fix":"Run 'canicode init' interactively or use 'canicode token-refresh <token>' separately.","message":"v0.12.0 split 'canicode init' into interactive setup and separate 'token-refresh' command. The old non-interactive 'init --token' is removed.","severity":"breaking","affected_versions":">=0.12.0"},{"fix":"Import from '@canicode/types' instead of 'canicode' for type-only imports.","message":"v0.11.0 deprecated direct export of 'RuleScore' type; use canonical types from '@canicode/types' if needed.","severity":"deprecated","affected_versions":">=0.11.0"},{"fix":"Review the annotation format; use 'allowDefinitionWrite' opt-in to propagate to component definitions.","message":"The roundtrip writes to Figma may produce '📝 annotated the scene node' markers; this is correct behavior when writing to instance children. It does not mean failure.","severity":"gotcha","affected_versions":">=0.11.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install canicode' in your project and ensure node_modules contains it.","cause":"Installed as global but used as local import without adding to package.json or running from wrong directory.","error":"Error: Cannot find module 'canicode'"},{"fix":"Update to v0.11.0+ with 'npm install canicode@latest'.","cause":"Using outdated version <0.11.0 that did not export 'Analyzer' class.","error":"TypeError: analyzer.analyzeFile is not a function"},{"fix":"Generate a new personal access token with 'write' scope in Figma account settings.","cause":"Insufficient Figma token permissions (read-only token used for write operations).","error":"Figma API error: 403 Forbidden"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}