Registry / devops / canicode

canicode

JSON →
library0.12.3jsnpmunverified

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.

npm install canicode
INSTALL
IMPORT
SIG · CANICODE
C
canicode
devopsjavascriptv0.12.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import canicode from 'canicode'
const canicode = require('canicode')
ESM-only package; requires Node >=22. No default export in current API; prefer named CLI usage.
Analyzer
import { Analyzer } from 'canicode'
import Analyzer from 'canicode/Analyzer'
Named export for programmatic analysis. TypeScript types are bundled.
Roundtrip
import { Roundtrip } from 'canicode'
import { Roundtrip } from 'canicode/roundtrip'
Named export for the roundtrip (write-to-Figma) workflow. Introduced in v0.11.0.

Shows programmatic usage to analyze a Figma file and print grade, rule results, and gotchas.

#!/usr/bin/env node import { Analyzer } from 'canicode'; const figmaToken = process.env.FIGMA_TOKEN ?? ''; const fileKey = process.env.FIGMA_FILE_KEY ?? ''; const analyzer = new Analyzer({ token: figmaToken }); async function main() { const result = await analyzer.analyzeFile(fileKey); console.log('Overall grade:', result.grade); console.log('Rule results:', JSON.stringify(result.rules, null, 2)); console.log('Gotchas:', result.gotchas); } main().catch(console.error);
canicode --version
Debug
Known issues
breakingv0.12.0 removed the '--api' flag from 'analyze' subcommand. Use 'FIGMA_TOKEN' env var or config file instead.
fix
Set FIGMA_TOKEN environment variable or use 'canicode init --token' to configure.
affects: >=0.12.0
breakingv0.12.0 split 'canicode init' into interactive setup and separate 'token-refresh' command. The old non-interactive 'init --token' is removed.
fix
Run 'canicode init' interactively or use 'canicode token-refresh <token>' separately.
affects: >=0.12.0
deprecatedv0.11.0 deprecated direct export of 'RuleScore' type; use canonical types from '@canicode/types' if needed.
fix
Import from '@canicode/types' instead of 'canicode' for type-only imports.
affects: >=0.11.0
gotchaThe 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.
fix
Review the annotation format; use 'allowDefinitionWrite' opt-in to propagate to component definitions.
affects: >=0.11.0
Errors
Common errors & fixes
Error: Cannot find module 'canicode'
Installed as global but used as local import without adding to package.json or running from wrong directory.
fix
Run 'npm install canicode' in your project and ensure node_modules contains it.
TypeError: analyzer.analyzeFile is not a function
Using outdated version <0.11.0 that did not export 'Analyzer' class.
fix
Update to v0.11.0+ with 'npm install canicode@latest'.
Figma API error: 403 Forbidden
Insufficient Figma token permissions (read-only token used for write operations).
fix
Generate a new personal access token with 'write' scope in Figma account settings.
Upgrade
Version history
0.12.3latest on npm
Audit
Dependencies
figma-apirequiredUsed to interact with Figma REST API for reading and writing design data
Agent activity
15 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
canicode — npm install canicode · libregistry