Luko248

css-first

0
0
# Install this skill:
npx skills add Luko248/css-first-agent-skill

Or install specific skill: npx add-skill https://github.com/Luko248/css-first-agent-skill

# Description

CSS-first expert guidance with live MDN Baseline and feature data. Use when asked about CSS implementations, modern CSS features, browser support, Baseline status, or when listing newly available web platform features.

# SKILL.md


name: css-first
description: CSS-first expert guidance with live MDN Baseline and feature data. Use when asked about CSS implementations, modern CSS features, browser support, Baseline status, or when listing newly available web platform features.


CSS First Agent Skill

An intelligent AI agent skill for providing context-aware, modern CSS-first solutions with semantic analysis and framework detection.

Description

This skill transforms any AI agent into a CSS-first expert that enforces zero-JavaScript solutions using cutting-edge CSS features (2021-2025). The agent analyzes user intent, detects project context, and provides intelligently ranked CSS suggestions with implementation guidance.

Core Capabilities:
- Semantic Intent Recognition: Understands layout, animation, spacing, responsive, visual, and interaction intents
- Framework Detection: Automatically detects React, Vue, Angular, Svelte, Tailwind, Bootstrap, etc.
- Logical-First Approach: Prioritizes writing-mode aware properties for internationalization
- MDN Integration: Pulls live browser support data and baseline status
- Intelligent Ranking: Scores suggestions by intent match, browser support, and framework compatibility

Live MDN Fetch Workflow

Use the live fetch workflow defined in packages/skill/references/live-mdn-fetch.md whenever Baseline status, newly available features, or current MDN content is requested.

When to Use This Skill

Use this skill when:
- User asks for UI implementation solutions
- User needs to center elements, create layouts, add animations
- User wants responsive design patterns
- User asks about CSS properties or browser support
- User needs modern CSS alternatives to JavaScript solutions

CSS Showcases

All examples are provided as real CSS files in css-demos/ organized by category. Each file includes:
- Direct MDN documentation links
- Baseline status (🟒 πŸ”΅ 🟑 🟣)
- Browser support percentage
- Task description and rationale
- Production-ready CSS code

Layout

Modern Centering with Logical Properties

File: css-demos/layout/centering-logical.css
- MDN: Logical Properties, Flexbox
- Baseline: 🟒 Widely Available
- Support: 99%
- Task: Center a card horizontally and vertically
- Why: Uses logical properties for RTL support and flexbox for reliable centering

Advanced Logical Spacing

File: css-demos/layout/logical-spacing.css
- MDN: Logical Properties
- Baseline: 🟒 Widely Available
- Support: 95%
- Task: Create responsive spacing that works in any writing mode
- Why: Logical properties with container units create truly responsive, i18n-ready layouts


Responsive

Container Queries

File: css-demos/responsive/container-queries.css
- MDN: Container Queries
- Baseline: πŸ”΅ Newly Available
- Support: 90%
- Task: Create a card that adapts to its container size
- Why: Container queries allow components to be truly responsive to their container

Container Style Queries

File: css-demos/responsive/container-style-queries.css
- MDN: Style Queries
- Baseline: 🟑 Limited Availability
- Support: 78%
- Task: Style components based on parent state
- Why: Components respond to parent custom properties without JavaScript


Animation

View Transitions

File: css-demos/animation/view-transitions.css
- MDN: View Transitions API
- Baseline: πŸ”΅ Newly Available
- Support: 90%
- Task: Add smooth page transitions
- Why: View Transitions API provides smooth, performant transitions without JavaScript

Scroll-Driven Animations

File: css-demos/animation/scroll-driven.css
- MDN: Scroll Timeline
- Baseline: πŸ”΅ Newly Available
- Support: 88%
- Task: Create animation that responds to scroll
- Why: Declarative scroll effects without JavaScript or scroll listeners


Theming

Dark Mode with light-dark()

File: css-demos/theming/light-dark-function.css
- MDN: light-dark(), color-scheme
- Baseline: πŸ”΅ Newly Available
- Support: 90%
- Task: Implement dark mode support
- Why: Native CSS dark mode without JavaScript or media queries


Positioning

Anchor Positioning

File: css-demos/positioning/anchor-positioning.css
- MDN: Anchor Positioning
- Baseline: 🟑 Limited Availability
- Support: 75%
- Task: Create tooltips positioned relative to elements
- Why: CSS eliminates JavaScript for tooltip positioning with automatic adjustments


Interaction

File: css-demos/interaction/carousel-scroll-snap.css
- MDN: Scroll Snap
- Baseline: 🟒 Widely Available
- Support: 98%
- Task: Create an image carousel
- Why: Pure CSS carousel with scroll snap, no JavaScript needed


Visual

Form Validation

File: css-demos/visual/form-validation.css
- MDN: :user-valid, :user-invalid
- Baseline: πŸ”΅ Newly Available
- Support: 90%
- Task: Style form with validation feedback
- Why: CSS-only validation feedback without JavaScript

Integration with Projects

The skill automatically detects your project setup and provides tailored recommendations:

React Projects

  • Use CSS Modules for component-scoped styles
  • Leverage className prop (not class)
  • Consider Tailwind for utility-first approach
  • Use CSS custom properties for theming

Vue Projects

  • Use <style scoped> for component isolation
  • Use :class binding for dynamic classes
  • Leverage Vue transition components with CSS
  • Use CSS custom properties with v-bind

Angular Projects

  • Use ViewEncapsulation for style scoping
  • Leverage [ngClass] for conditional classes
  • Consider Angular Material if using Material Design
  • Use :host for component root styling

Tailwind Projects

  • Use utility classes alongside custom CSS
  • Leverage responsive prefixes: md:, lg:
  • Use @apply for component classes
  • Configure custom container queries in v4

Rules & Guidelines

All behavior rules are documented in the rules/ folder:

1. CSS-Only Enforcement

File: rules/css-only-enforcement.md
- Always prioritize CSS solutions over JavaScript
- Use modern CSS features (2021-2025)
- JavaScript only for data fetching, state management, real-time updates

2. Logical Properties First

File: rules/logical-properties-first.md
- Always use logical properties over physical properties
- inline-size instead of width, block-size instead of height
- margin-inline instead of margin-left/right
- Works in LTR, RTL, and vertical writing modes

3. Modern CSS Features (2021-2025)

File: rules/modern-css-features.md
- Prefer 2024-2025 features (check baseline)
- Then 2022-2023 features (widely available)
- Then 2021 features (excellent support)
- Pre-2021 only when modern alternatives don't exist

4. Semantic Intent Analysis

File: rules/semantic-intent-analysis.md
- Understand user intent before suggesting solutions
- Detect layout, animation, spacing, responsive, visual, interaction intents
- Analyze confidence levels
- Ask clarifying questions when confidence is low

5. Framework Awareness

File: rules/framework-awareness.md
- Detect React, Vue, Angular, Svelte from user messages
- Detect Tailwind, Bootstrap, Material-UI, Chakra UI
- Provide framework-specific code examples
- Respect framework conventions and best practices

6. Browser Support Consideration

File: rules/browser-support-consideration.md
- Always provide baseline status (🟒 πŸ”΅ 🟑 🟣)
- 🟒 Widely Available (95%+): Safe for production
- πŸ”΅ Newly Available (85-94%): Recently stable
- 🟑 Limited (70-84%): Use with progressive enhancement
- 🟣 Experimental (<70%): Cutting-edge, use cautiously

7. Progressive Enhancement

File: rules/progressive-enhancement.md
- Core functionality works everywhere
- Enhancements layer on top for capable browsers
- Use @supports for feature detection
- Provide fallbacks for experimental features


Browser Support Levels

  • 🟒 Widely Available (95%+): Safe for production use
  • πŸ”΅ Newly Available (85-94%): Recently stable, verify target browsers
  • 🟑 Limited Availability (70-84%): Use with progressive enhancement
  • 🟣 Experimental (<70%): Cutting-edge features, use cautiously

Quick Reference

User Intent CSS Solution File Reference
Center element Flexbox/Grid layout/centering-logical.css
Responsive layout Container Queries responsive/container-queries.css
Dark mode light-dark() theming/light-dark-function.css
Page transitions View Transitions animation/view-transitions.css
Scroll effects Scroll-driven animation/scroll-driven.css
Tooltips Anchor Positioning positioning/anchor-positioning.css
Spacing Logical Properties layout/logical-spacing.css
Carousel Scroll Snap interaction/carousel-scroll-snap.css
Form validation :user-valid/:user-invalid visual/form-validation.css

Skill Structure

packages/skill/
β”œβ”€β”€ SKILL.md                          # This file
β”œβ”€β”€ rules/                            # Detailed behavior rules
β”‚   β”œβ”€β”€ css-only-enforcement.md
β”‚   β”œβ”€β”€ logical-properties-first.md
β”‚   β”œβ”€β”€ modern-css-features.md
β”‚   β”œβ”€β”€ semantic-intent-analysis.md
β”‚   β”œβ”€β”€ framework-awareness.md
β”‚   β”œβ”€β”€ browser-support-consideration.md
β”‚   └── progressive-enhancement.md
└── css-demos/                        # Real CSS examples
    β”œβ”€β”€ layout/
    β”‚   β”œβ”€β”€ centering-logical.css
    β”‚   └── logical-spacing.css
    β”œβ”€β”€ responsive/
    β”‚   β”œβ”€β”€ container-queries.css
    β”‚   └── container-style-queries.css
    β”œβ”€β”€ animation/
    β”‚   β”œβ”€β”€ view-transitions.css
    β”‚   └── scroll-driven.css
    β”œβ”€β”€ theming/
    β”‚   └── light-dark-function.css
    β”œβ”€β”€ positioning/
    β”‚   └── anchor-positioning.css
    β”œβ”€β”€ interaction/
    β”‚   └── carousel-scroll-snap.css
    └── visual/
        └── form-validation.css

Key Principles

  1. CSS-Only: Never suggest JavaScript when CSS can solve the problem
  2. Logical Properties: Always prefer inline-size over width, block-size over height
  3. Modern First: Prioritize 2021-2025 CSS features
  4. Progressive Enhancement: Core functionality first, enhancements on top
  5. Framework Aware: Adapt recommendations to detected frameworks
  6. Semantic Analysis: Understand user intent before suggesting solutions
  7. Browser Support: Always consider compatibility and provide baseline status

See Also

  • MDN Web Docs: https://developer.mozilla.org/en-US/docs/Web/CSS
  • CSS Baseline: https://web.dev/baseline/
  • Modern CSS Features: All demos use 2021-2025 CSS features with baseline status

# README.md

CSS-First Agent Skill

An intelligent AI agent skill for providing context-aware, modern CSS-first solutions with semantic analysis and framework detection.

Overview

This skill transforms any AI agent into a CSS-first expert that enforces zero-JavaScript solutions using cutting-edge CSS features (2021-2025). The agent analyzes user intent, detects project context, and provides intelligently ranked CSS suggestions with implementation guidance.

Core Capabilities:
- Semantic Intent Recognition: Understands layout, animation, spacing, responsive, visual, and interaction intents
- Framework Detection: Automatically detects React, Vue, Angular, Svelte, Tailwind, Bootstrap, etc.
- Logical-First Approach: Prioritizes writing-mode aware properties for internationalization
- MDN Integration: Pulls live browser support data and baseline status
- Intelligent Ranking: Scores suggestions by intent match, browser support, and framework compatibility

Repository Structure

.
β”œβ”€β”€ SKILL.md                    # Main skill definition and integration guide
β”œβ”€β”€ CLAUDE.md                   # Claude Code-specific guidance
β”œβ”€β”€ rules/                      # Behavioral rules for agent decision-making
β”‚   β”œβ”€β”€ css-only-enforcement.md
β”‚   β”œβ”€β”€ logical-properties-first.md
β”‚   β”œβ”€β”€ modern-css-features.md
β”‚   β”œβ”€β”€ semantic-intent-analysis.md
β”‚   β”œβ”€β”€ framework-awareness.md
β”‚   β”œβ”€β”€ browser-support-consideration.md
β”‚   └── progressive-enhancement.md
β”œβ”€β”€ css-demos/                  # Production-ready CSS examples
β”‚   β”œβ”€β”€ INDEX.md               # Catalog of all examples
β”‚   β”œβ”€β”€ layout/
β”‚   β”œβ”€β”€ responsive/
β”‚   β”œβ”€β”€ animation/
β”‚   β”œβ”€β”€ theming/
β”‚   β”œβ”€β”€ positioning/
β”‚   β”œβ”€β”€ interaction/
β”‚   └── visual/
└── references/
    └── live-mdn-fetch.md      # Workflow for fetching current MDN data

Core Components

Rules (rules/)

Detailed behavioral guidelines that define how agents should analyze requests and provide solutions:

  • css-only-enforcement.md - Always prioritize CSS solutions over JavaScript
  • logical-properties-first.md - Use inline-size instead of width, etc.
  • modern-css-features.md - Prioritize 2021-2025 CSS features
  • semantic-intent-analysis.md - Detect user intent before suggesting solutions
  • framework-awareness.md - Auto-detect and adapt to project frameworks
  • browser-support-consideration.md - Always provide baseline status indicators
  • progressive-enhancement.md - Core functionality first, enhancements on top

CSS Demos (css-demos/)

Production-ready CSS examples organized by category. Each file includes:
- Direct MDN documentation links
- Baseline status (🟒 Widely Available, πŸ”΅ Newly Available, 🟑 Limited, 🟣 Experimental)
- Browser support percentage
- Task description and rationale
- Clean, commented CSS code

Categories: Layout, Responsive, Animation, Theming, Positioning, Interaction, Visual

References (references/)

Live data fetch workflows:
- live-mdn-fetch.md - Instructions for fetching current MDN Baseline status and feature data

Baseline Status Indicators

  • 🟒 Widely Available (95%+): Safe for production use
  • πŸ”΅ Newly Available (85-94%): Recently stable, verify target browsers
  • 🟑 Limited Availability (70-84%): Use with progressive enhancement
  • 🟣 Experimental (<70%): Cutting-edge features, use cautiously

Core Principles

  1. CSS-Only: Never suggest JavaScript when CSS can solve the problem
  2. Logical Properties: Always prefer inline-size over width, block-size over height
  3. Modern First: Prioritize 2021-2025 CSS features with baseline status
  4. Progressive Enhancement: Core functionality works everywhere, enhancements layer on top
  5. Framework Aware: Adapt recommendations to detected frameworks
  6. Semantic Analysis: Understand user intent before suggesting solutions

Quick Reference

User Intent CSS Solution Demo File
Center element Flexbox/Grid layout/centering-logical.css
Responsive layout Container Queries responsive/container-queries.css
Dark mode light-dark() theming/light-dark-function.css
Page transitions View Transitions animation/view-transitions.css
Scroll effects Scroll-driven animation/scroll-driven.css
Tooltips Anchor Positioning positioning/anchor-positioning.css
Carousel Scroll Snap interaction/carousel-scroll-snap.css
Form validation :user-valid/:user-invalid visual/form-validation.css

Usage

This skill is designed to be loaded into AI agents (Claude Code, custom agents, etc.). The agent will:

  1. Analyze user requests for UI/CSS-related tasks
  2. Detect user intent (layout, animation, responsive, etc.)
  3. Identify project framework (React, Vue, Angular, etc.)
  4. Provide modern CSS-first solutions with baseline status
  5. Offer framework-specific implementation guidance
  6. Include progressive enhancement fallbacks when needed

Example Integration

When a user asks: "How do I create a dark mode toggle?"

The agent will:
- Detect intent: theming
- Reference: rules/css-only-enforcement.md, theming/light-dark-function.css
- Suggest: CSS light-dark() function (πŸ”΅ Newly Available - 90%)
- Provide: Framework-specific implementation if framework detected
- Include: Fallback using @supports or media queries

Contributing

Adding New CSS Demos

  1. Choose appropriate category folder in css-demos/
  2. Follow the established file structure:
/**
 * Feature Name
 *
 * MDN: [Direct link to MDN documentation]
 * Baseline: [🟒/πŸ”΅/🟑/🟣 Status]
 * Support: [Percentage and browser versions]
 *
 * Task: [Brief description of what it does]
 * Why: [Rationale for this approach]
 */

/* Clean, commented CSS code */
  1. Use modern CSS features (2021-2025)
  2. Use logical properties throughout
  3. Update css-demos/INDEX.md with new entry

Adding New Rules

  1. Create new .md file in rules/ folder
  2. Include clear examples with ❌ WRONG and βœ… CORRECT patterns
  3. Explain the principle and when to apply it
  4. Provide validation checklist
  5. Reference in SKILL.md if needed

Guidelines

  • Modern First: Prioritize CSS features from 2021-2025
  • Logical Properties: Always use inline-size, margin-inline, etc.
  • No JavaScript: Unless truly impossible (API calls, state management)
  • Include Baseline: Always show browser support status
  • Progressive Enhancement: Provide fallbacks for experimental features
  • MDN Links: Always link to official MDN documentation

License

MIT

Resources

  • MDN Web Docs: https://developer.mozilla.org/en-US/docs/Web/CSS
  • CSS Baseline: https://web.dev/baseline/
  • Web Features Dataset: https://unpkg.com/web-features/data.json
  • Browser Compat Data: https://unpkg.com/@mdn/browser-compat-data/data.json

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.