| id | SKL-tailwind-TAILWINDPATTERNS |
| name | Tailwind Patterns |
| description | Tailwind CSS is a utility-first CSS framework that helps developers build UI rapidly and maintainably using utility classes instead of custom CSS. This approach reduces context switching between HTML |
| version | 1.0.0 |
| status | active |
| owner | @cerebra-team |
| last_updated | 2026-02-22 |
| category | Backend |
| tags | ["api","backend","server","database"] |
| stack | ["Python","Node.js","REST API","GraphQL"] |
| difficulty | Intermediate |
Tailwind Patterns
Skill Profile
(Select at least one profile to enable specific modules)
Overview
Tailwind CSS is a utility-first CSS framework that helps developers build UI rapidly and maintainably using utility classes instead of custom CSS. This approach reduces context switching between HTML and CSS files. Tailwind CSS uses a utility-first approach which helps developers build UI rapidly with utility classes, maintain consistency with design tokens, create responsive layouts easily, support dark mode natively, fully customize through configuration files, and optimize for production with JIT mode that removes unused styles automatically.
Why This Matters
- Increases Development Velocity: Reduces UI development time by 30-50%
- Reduces CSS Bundle Size: Purges unused styles, reducing bundle size by up to 80%
- Increases Maintainability: Consistent design tokens improve maintainability
- Reduces Context Switching: Utility classes reduce switching between HTML and CSS
- Improves Consistency: Consistent design system improves UX
Core Concepts
Inputs / Outputs / Contracts
- Inputs:
- <e.g., env vars, request payload, file paths, schema>
- Entry Conditions:
- <Pre-requisites: e.g., Repo initialized, DB running, specific branch checked out>
- Outputs:
- <e.g., artifacts (PR diff, docs, tests, dashboard JSON)>
- Artifacts Required (Deliverables):
- <e.g., Code Diff, Unit Tests, Migration Script, API Docs>
- Acceptance Evidence:
- <e.g., Test Report (screenshot/log), Benchmark Result, Security Scan Report>
- Success Criteria:
- <e.g., p95 < 300ms, coverage ≥ 80%>
Skill Composition
Quick Start
- Install Tailwind CSS: Install Tailwind and dependencies
- Initialize Configuration: Create tailwind.config.js
- Add Directives: Add Tailwind directives to CSS
- Customize Theme: Extend theme with design tokens
- Build Components: Build components using utility classes
- Add Responsive: Add responsive modifiers
- Implement Dark Mode: Add dark mode support
- Optimize Build: Configure purge and optimization
- Document Patterns: Document common patterns
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
module.exports = {
content: [
'./src/**/*.{js,ts,jsx,tsx,mdx}',
'./app/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {},
},
plugins: [],
}
@tailwind base;
@tailwind components;
@tailwind utilities;
Assumptions / Constraints / Non-goals
- Assumptions:
- Development environment is properly configured
- Required dependencies are available
- Team has basic understanding of domain
- Constraints:
- Must follow existing codebase conventions
- Time and resource limitations
- Compatibility requirements
- Non-goals:
- This skill does not cover edge cases outside scope
- Not a replacement for formal training
Compatibility & Prerequisites
- Supported Versions:
- Python 3.8+
- Node.js 16+
- Modern browsers (Chrome, Firefox, Safari, Edge)
- Required AI Tools:
- Code editor (VS Code recommended)
- Testing framework appropriate for language
- Version control (Git)
- Dependencies:
- Language-specific package manager
- Build tools
- Testing libraries
- Environment Setup:
.env.example keys: API_KEY, DATABASE_URL (no values)
Test Scenario Matrix (QA Strategy)
| Type | Focus Area | Required Scenarios / Mocks |
|---|
| Unit | Core Logic | Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |
| Integration | DB / API | All external API calls or database connections must be mocked during unit tests |
| E2E | User Journey | Critical user flows to test |
| Performance | Latency / Load | Benchmark requirements |
| Security | Vuln / Auth | SAST/DAST or dependency audit |
| Frontend | UX / A11y | Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |
Technical Guardrails & Security Threat Model
1. Security & Privacy (Threat Model)
- Top Threats: Injection attacks, authentication bypass, data exposure
2. Performance & Resources
3. Architecture & Scalability
4. Observability & Reliability
Agent Directives & Error Recovery
(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)
- Thinking Process: Analyze root cause before fixing. Do not brute-force.
- Fallback Strategy: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.
- Self-Review: Check against Guardrails & Anti-patterns before finalizing.
- Output Constraints: Output ONLY the modified code block. Do not explain unless asked.
Definition of Done (DoD) Checklist
Anti-patterns
- Over-Engineering: Using Tailwind for simple projects adds unnecessary complexity
- Poor Configuration: Poor configuration leads to inconsistent styling
- Missing Purge: Not purging unused styles causes large bundle sizes
- Inconsistent Design: Inconsistent use of design tokens reduces maintainability
- Poor Performance: Not optimizing bundle size causes slow load times
- Accessibility Issues: Not considering accessibility limits user base
- Over-using Arbitrary Values: Excessive arbitrary values reduce maintainability
- Not Organizing Classes: Poorly organized classes are hard to read
- Ignoring Responsive: Not considering responsive design causes poor UX
- Not Using @apply: Not using @apply for repeated patterns causes code duplication
Reference Links & Examples
- Internal documentation and examples
- Official documentation and best practices
- Community resources and discussions
Versioning & Changelog
- Version: 1.0.0
- Changelog:
- 2026-02-22: Initial version with complete template structure