Skip to content

Add AI context generation system for multi-tool agent routing#1548

Open
abhakat wants to merge 5 commits intomainfrom
rules-and-skills
Open

Add AI context generation system for multi-tool agent routing#1548
abhakat wants to merge 5 commits intomainfrom
rules-and-skills

Conversation

@abhakat
Copy link
Contributor

@abhakat abhakat commented Mar 25, 2026

What changed / motivation?

AI agents (Cursor, Copilot, Claude Code, Gemini, Codex) need StyleX-specific context to avoid common mistakes like using legacy contextual syntax, writing disallowed shorthands, or misconfiguring bundler plugins. This PR adds a codegen system that produces tool-native context files from a single source of truth.

What's included:

  • ai-dev/plugins/ — canonical workflow plugins (setup, authoring, maintainers) as JSON, plus index.json registry with validation commands, package map, conventions, and do-not rules
  • tools/ai-context/generate-agents.js — generator that reads plugins and produces all tool-specific outputs below
  • Generated outputs (root): AGENTS.md, CLAUDE.md, GEMINI.md
  • Generated outputs (Copilot): .github/copilot-instructions.md, .github/instructions/*.instructions.md
  • Generated outputs (Cursor): .cursor/rules/*.mdc
  • Generated outputs (docs): packages/docs/static/llm/AGENTS.md, packages/docs/static/llms.txt
  • defineConsts extension nuance added to packages/docs/static/llm/stylex-authoring.md
  • ai:check-context drift detection wired into npm test

Design principles:

  • One fact, one home — canonical content stays in packages/docs/static/llm/, metadata in ai-dev/plugins/, generated files are read-only routers
  • Tool-native formats — Cursor gets .mdc with globs frontmatter, Copilot gets applyTo scoped instructions, Claude/Gemini get markdown routers
  • Maintainer context is scoped — WF-MAINTAIN details only appear in scoped files, not global routers

Linked PR/Issues

Closes #1450
Closes #1256

Additional Context

node tools/ai-context/generate-agents.js --check passes.
npx eslint tools/ai-context/generate-agents.js passes.

Generated files are intentionally thin — they route to existing canonical docs (stylex-installation.md, stylex-authoring.md, eslint-plugin/README.md) rather than duplicating content.

Pre-flight checklist

Anay Bhakat added 5 commits March 23, 2026 10:19
…rthands

Add animation shorthand expansion following the createSpecificTransformer
pattern. The rule now reports an error and autofixes when users write
`animation: 'slidein 3s ease-in'` instead of the expanded longhands.

Handles all CSS spec cases:
- Duration and delay (first time = duration, second = delay)
- Timing functions: keywords (ease, linear, etc.) and functions
  (cubic-bezier(), steps())
- Iteration count: number or infinite
- Direction: normal, reverse, alternate, alternate-reverse
- Fill mode: forwards, backwards, both
- Play state: running, paused
- Animation name: any unclassified identifier
- Comma-separated multi-animation returns CANNOT_FIX
- !important support
- Add canonical workflow plugins (ai-dev/plugins/) for setup, authoring, and maintainer workflows
- Add generator (tools/ai-context/generate-agents.js) that produces thin router files for Codex, Claude, Gemini, Cursor, and Copilot from a single source of truth
- Add drift detection (ai:check-context) wired into the test script
- Add llms.txt at docs static root for external tool discovery
- Add validation commands, package map, conventions, do-not rules, and local override support to index.json
- Add defineConsts extension nuance to authoring doc
- Remove stylex-skills-rules-architecture.md from WF-MAINTAIN sources (meta-planning doc, not compiler context)
- Keep WF-MAINTAIN detail in scoped files only, not global routers
@vercel
Copy link

vercel bot commented Mar 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stylex Ready Ready Preview, Comment Mar 25, 2026 0:06am

Request Review

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 25, 2026
@github-actions
Copy link

workflow: benchmarks/size

Comparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.
yarn workspace v1.22.22
yarn run v1.22.22
$ node ./compare.js /tmp/tmp.IzRHKbNSZd /tmp/tmp.8TxvDVqd2p

Results Base Patch Ratio
@stylexjs/stylex/lib/cjs/stylex.js
· compressed 1,447 1,447 1.00
· minified 4,558 4,558 1.00
@stylexjs/stylex/lib/cjs/inject.js
· compressed 1,793 1,793 1.00
· minified 4,915 4,915 1.00
benchmarks/size/.build/bundle.js
· compressed 496,650 496,650 1.00
· minified 4,847,840 4,847,840 1.00
benchmarks/size/.build/stylex.css
· compressed 99,653 99,653 1.00
· minified 747,850 747,850 1.00
Done in 0.08s.
Done in 0.33s.

@github-actions
Copy link

workflow: benchmarks/perf

Comparison of performance test results, measured in operations per second. Larger is better.
yarn workspace v1.22.22
yarn run v1.22.22
$ node ./compare.js /tmp/tmp.wN6LsAgLXQ /tmp/tmp.WQCOPU7PNj

Results Base Patch Ratio
babel-plugin: stylex.create
· basic create 526 525 1.00 -
· complex create 65 65 1.00
babel-plugin: stylex.createTheme
· basic themes 433 433 1.00
· complex themes 34 33 0.97 -
Done in 0.09s.
Done in 0.34s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClaudeCode StyleX Skills [docs] Add LLM context files

1 participant