โ† Back to Skills

progressive-enhancement

thkt
Updated Yesterday
31 views
3
3
View on GitHub
Designaidesign

About

This Claude Skill promotes a CSS-first approach to web development, prioritizing CSS solutions over JavaScript for layout, styling, animations, and responsive design. It guides developers to create simple, maintainable, and performant implementations by defaulting to CSS-only solutions whenever possible. Use it when working with CSS Grid, Flexbox, toggles, or show/hide functionality to apply YAGNI and "the best code is no code" principles.

Documentation

Progressive Enhancement - CSS-First Development

๐ŸŽฏ Core Philosophy

"The best code is no code" - If CSS can solve it, JavaScript is unnecessary

Priority

  1. HTML - Structure and semantics
  2. CSS - Visual presentation and layout
  3. JavaScript - Only when truly necessary

๐ŸŽจ CSS-First Solutions

Layout

Grid

/* โœ… CSS Grid overlay */
.container {
  display: grid;
}

.background, .foreground {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
}

/* โŒ No JavaScript needed: avoid position: absolute */

Use cases:

  • Modal overlays
  • Badge positioning on cards
  • Layering background images with foreground content

Flexbox

/* โœ… Center alignment */
.center {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* โŒ No JavaScript needed: manual calculation and position setting */

Position

/* โœ… Transform - no reflow */
.move-up {
  transform: translateY(-10px);
  transition: transform 0.3s;
}

/* โŒ Avoid top/left (causes reflow) */
.move-up-bad {
  position: relative;
  top: -10px;  /* Triggers reflow */
}

Performance:

  • transform: GPU accelerated, no reflow
  • top/left/margin: CPU rendering, causes reflow

Show/Hide

/* โœ… visibility/opacity for animations */
.hidden {
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s, visibility 0s 0.3s;
}

.visible {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.3s;
}

/* โŒ display: none disappears instantly, no animation */

Responsive

Media Queries

/* โœ… Mobile-first */
.component {
  /* Mobile default styles */
  flex-direction: column;
}

@media (min-width: 768px) {
  .component {
    flex-direction: row;
  }
}

/* โŒ No JavaScript needed: window.innerWidth detection */

Container Queries

/* โœ… Based on component's own size */
.card-container {
  container-type: inline-size;
}

@container (min-width: 400px) {
  .card {
    grid-template-columns: 1fr 1fr;
  }
}

/* โŒ ResizeObserver not needed */

State Management

:target

/* โœ… URL hash-based state management */
.modal {
  display: none;
}

.modal:target {
  display: flex;
}

/* HTML: <a href="#modal">Open</a> */
/* โŒ No JavaScript needed: showModal(), hideModal() */

:checked

/* โœ… Checkbox state management */
.toggle:checked ~ .content {
  max-height: 500px;
  opacity: 1;
}

.toggle:not(:checked) ~ .content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

/* โŒ No JavaScript needed: toggleClass() */

:has()

/* โœ… Parent element styling */
.form:has(input:invalid) .submit-button {
  opacity: 0.5;
  cursor: not-allowed;
}

/* โŒ No JavaScript needed: input.addEventListener('invalid') */

๐Ÿ”€ Common Patterns

Accordion

<details>
  <summary>Click to expand</summary>
  <p>Expanded content</p>
</details>
details {
  border: 1px solid #ddd;
}

summary {
  cursor: pointer;
  padding: 1rem;
}

summary::marker {
  content: 'โ–ถ ';
}

details[open] summary::marker {
  content: 'โ–ผ ';
}

/* โŒ No JavaScript needed: onClick, setState, CSS class toggle */

Benefits:

  • Browser native
  • Accessibility built-in
  • Keyboard navigation supported

Tooltip

.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0s 0.3s;
}

.tooltip:hover::after,
.tooltip:focus::after {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s;
}

/* HTML: <button class="tooltip" data-tooltip="Hint">Button</button> */
/* โŒ No JavaScript needed: position calculation, show/hide control */

Modal

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);

  display: none;
  place-items: center;
}

.modal:target {
  display: grid;
}

/* HTML: <a href="#myModal">Open</a> */
/* HTML: <div id="myModal" class="modal">...</div> */
/* โŒ No JavaScript needed: openModal(), closeModal() */

โš–๏ธ When JavaScript is Needed

CSS is Sufficient For

  • โœ… Static animations
  • โœ… Hover, focus, checkbox state changes
  • โœ… Simple show/hide toggles
  • โœ… Responsive layouts
  • โœ… URL-based state management

JavaScript is Required For

  • โŒ API data fetching
  • โŒ Form submission and validation
  • โŒ Complex state management (multiple interactions)
  • โŒ Dynamic content generation
  • โŒ Browser API usage (localStorage, WebSocket, etc.)

๐Ÿš€ Decision Framework

Before implementation, ask yourself:

1. "Can this be done with CSS alone?"

Layout โ†’ Grid/Flexbox
Position โ†’ Transform
Display control โ†’ visibility/opacity
State management โ†’ :target, :checked, :has()
Animation โ†’ transition/animation

2. "Is this really needed now?" (YAGNI)

โ“ Is there an actual problem occurring?
โ“ Have users requested this?
โ“ Is there measurable evidence?

All No โ†’ Don't implement yet

3. "What's the simplest solution?" (Occam's Razor)

Option A: 3 lines of CSS
Option B: 50 lines of JavaScript + 10 lines of CSS

โ†’ Choose Option A

๐Ÿ’ก Practical Application

Auto-Trigger Example

User: "I want cards to scale up on hover"

Skill auto-triggers โ†’

"From a Progressive Enhancement perspective, this can be achieved with CSS transform:

    ```css
    .card {
      transition: transform 0.3s;
    }

    .card:hover {
      transform: scale(1.05);
    }
    ```

No JavaScript needed."

Common Suggestion Patterns

  1. Layout questions

    • "Let's consider if Grid/Flexbox can solve this"
  2. Animation questions

    • "Would CSS transition be sufficient?"
  3. State management questions

    • "We can manage state with :checked or :has()"
  4. Responsive questions

    • "Let's start with Media Queries"

๐Ÿ“š Related Principles

  • Occam's Razor: Prioritize simple solutions
  • YAGNI: Don't implement until truly needed
  • Outcome-First: Prioritize outcomes over architecture

โœจ Key Takeaways

  1. CSS-First: Consider CSS solutions first
  2. JavaScript-Last: Only when truly necessary
  3. Native-First: Leverage browser native features (<details>, :has(), etc.)
  4. Progressive: Start simple, enhance as needed

Remember: "The best code is code that doesn't need to exist"

Quick Install

/plugin add https://github.com/thkt/claude-config/tree/main/progressive-enhancement

Copy and paste this command in Claude Code to install this skill

GitHub ไป“ๅบ“

thkt/claude-config
Path: skills/progressive-enhancement

Related Skills

sglang

Meta

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

View skill

evaluating-llms-harness

Testing

This Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.

View skill

llamaguard

Other

LlamaGuard is Meta's 7-8B parameter model for moderating LLM inputs and outputs across six safety categories like violence and hate speech. It offers 94-95% accuracy and can be deployed using vLLM, Hugging Face, or Amazon SageMaker. Use this skill to easily integrate content filtering and safety guardrails into your AI applications.

View skill

langchain

Meta

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

View skill