TokenLock is an open-standard Agent Skill (SKILL.md) that prevents AI coding agents from corrupting production user interfaces with "vibecoded" arbitrary styles, fabricated hex codes, and component reinvention.
Human designers invest weeks crafting cohesive design systems (Tailwind theme scales, CSS variables, Figma tokens). However, when developers prompt an AI agent to build or edit screens:
- The AI hallucinates arbitrary pixels: It fabricates
p-[14px],m-[7px],w-[310px],rounded-[9px]rather than adhering to the 4px/8px grid scale (p-3.5,p-4,rounded-lg). - The AI invents custom hex codes: Rather than using semantic tokens (
bg-primary,text-muted-foreground), it approximates hex codes (#3468F8vs design#3B82F6), fragmenting the visual palette. - The AI rebuilds base components: It writes new inline
<button className="...">elements from scratch instead of consuming existing design system primitives (<Button>).
Run TokenLock on any component, folder, or pull request diff with zero configuration:
# 1. Audit current directory
$ tokenlock
# 2. Audit a specific folder or file
$ tokenlock src/components/
# 3. Automatically fix arbitrary bracket values in-place!
$ tokenlock --fix
# 4. Install automated pre-commit hook in 1 second
$ tokenlock --install-hook🚨 TokenLock: Found 3 design token drift violation(s):
• src/components/UserCard.tsx:4
Offender : p-[14px] (arbitrary_bracket)
Suggestion: p-3.5 (14px)
• src/components/UserCard.tsx:4
Offender : #0F172A (hardcoded_hex)
Suggestion: Use semantic theme color (e.g. text-foreground, bg-primary, var(--ink))
• src/components/UserCard.tsx:7
Offender : rounded-[9px] (arbitrary_bracket)
Suggestion: rounded-lg (8px)
💡 TokenLock: Found 2 auto-fixable violation(s). Apply fixes now? [Y/n]: y
🔧 Fixed 2 token violation(s) in src/components/UserCard.tsx
- The Token-First Rule: Inspect the project's token source of truth (
tailwind.config.*, CSS variables, theme objects) before writing styles. Never invent a color or spacing unit. - The Ban on Arbitrary Brackets: Never emit bracketed arbitrary overrides (
p-[...],rounded-[...]). Always map to the nearest valid scale token. - The Hex Code Prohibition: Zero raw hex strings in component markup. Always use semantic theme tokens.
- Primitive Component Reuse: Mandatory reuse of existing design system primitives (
<Button>,<Card>,<Input>) over inline reinventions.
Install directly into your project's skills directory:
git clone https://github.com/subinz1/tokenlock-skill.git .claude/skills/tokenlockCopy SKILL.md into your .cursor/rules/ directory or add it to Cursor Project Rules.
Clone into .codex/skills/ or reference SKILL.md in your system prompt.
Prevent arbitrary styles from ever entering git:
echo "python3 scripts/tokenlock.py --path src/" >> .git/hooks/pre-commit
chmod +x .git/hooks/pre-commitname: TokenLock Lint
on: [pull_request]
jobs:
tokenlock:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: python3 scripts/tokenlock.py --path src/ --strictTokenLock is built with zero external npm or pip dependencies. It runs on any standard Python 3.8+ runtime in under 5 milliseconds, making it fast enough to run on every file save and pre-commit hook.
tokenlock-skill/
├── SKILL.md # Universal Agent Skill specification
├── scripts/
│ └── tokenlock.py # Zero-dependency static token drift auditor
├── references/
│ └── TOKEN_TAXONOMY.md # 4px grid spacing tables & semantic token scale
├── fixtures/
│ ├── sloppy_component.tsx # Real-world AI-generated component with drift
│ └── locked_component.tsx # Token-hardened production version
├── tests/
│ └── test_tokenlock.py # Automated unit test suite
├── package.json
├── LICENSE # MIT License
└── TODO.md # Phase 2 roadmap (Figma API sync, auto-fixer)
MIT © Subin George