@schalkneethling/toolkit 0.1.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -7
- package/dist/index.mjs +90 -6
- package/dist/index.mjs.map +1 -1
- package/hooks/auto-approve-safe-commands/hook.mjs +134 -0
- package/hooks/auto-approve-safe-commands/hook.mts +188 -0
- package/hooks/auto-approve-safe-commands/settings-fragment.json +17 -0
- package/hooks/block-dangerous-commands/hook.mjs +3 -3
- package/hooks/block-dangerous-commands/hook.mts +23 -10
- package/package.json +8 -10
- package/skills/css-coder/SKILL.md +95 -0
- package/skills/css-coder/references/patterns.md +224 -0
- package/skills/css-tokens/README.md +152 -0
- package/skills/css-tokens/SKILL.md +125 -0
- package/skills/css-tokens/references/tokens.css +162 -0
- package/skills/frontend-security/SKILL.md +134 -0
- package/skills/frontend-security/references/csp-configuration.md +191 -0
- package/skills/frontend-security/references/csrf-protection.md +327 -0
- package/skills/frontend-security/references/dom-security.md +229 -0
- package/skills/frontend-security/references/file-upload-security.md +310 -0
- package/skills/frontend-security/references/framework-patterns.md +307 -0
- package/skills/frontend-security/references/input-validation.md +232 -0
- package/skills/frontend-security/references/jwt-security.md +300 -0
- package/skills/frontend-security/references/nodejs-npm-security.md +261 -0
- package/skills/frontend-security/references/xss-prevention.md +163 -0
- package/skills/frontend-testing/SKILL.md +357 -0
- package/skills/frontend-testing/references/accessibility-testing.md +368 -0
- package/skills/frontend-testing/references/aria-snapshots.md +517 -0
- package/skills/frontend-testing/references/locator-strategies.md +295 -0
- package/skills/frontend-testing/references/visual-regression.md +466 -0
- package/skills/refined-plan-mode/SKILL.md +84 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# CSS Design Tokens
|
|
2
|
+
|
|
3
|
+
## Quick Start
|
|
4
|
+
|
|
5
|
+
1. Install the skill in your project (see [main repo README](https://github.com/schalkneethling/claude-toolkit))
|
|
6
|
+
2. Import `tokens.css` in your main stylesheet or HTML
|
|
7
|
+
3. Start using tokens: `var(--color-primary)`, `var(--size-16)`, etc.
|
|
8
|
+
|
|
9
|
+
For the philosophy and detailed usage, read on below.
|
|
10
|
+
|
|
11
|
+
## Philosophy
|
|
12
|
+
|
|
13
|
+
This token system embodies several key principles:
|
|
14
|
+
|
|
15
|
+
### 1. Perceptual Uniformity
|
|
16
|
+
|
|
17
|
+
Colors use the `oklch()` color space rather than `hsl()` or `rgb()`. This ensures:
|
|
18
|
+
|
|
19
|
+
- Consistent perceived brightness across hues
|
|
20
|
+
- More predictable color manipulation
|
|
21
|
+
- Better accessibility through perceptual lightness control
|
|
22
|
+
|
|
23
|
+
### 2. Semantic Naming
|
|
24
|
+
|
|
25
|
+
Tokens are named by their purpose or scale value, not their appearance:
|
|
26
|
+
|
|
27
|
+
- `--color-primary` not `--color-teal`
|
|
28
|
+
- `--size-16` (16px value) not `--spacing-small`
|
|
29
|
+
- `--text-xl` (size indicator) not `--heading-size`
|
|
30
|
+
|
|
31
|
+
### 3. System Thinking
|
|
32
|
+
|
|
33
|
+
The design system is interconnected:
|
|
34
|
+
|
|
35
|
+
- Border radius values reference the spacing scale
|
|
36
|
+
- Typography sizes follow a modular scale
|
|
37
|
+
- Z-index uses named layers, not arbitrary numbers
|
|
38
|
+
|
|
39
|
+
### 4. Dark Mode First-Class
|
|
40
|
+
|
|
41
|
+
Dark mode isn't an afterthought:
|
|
42
|
+
|
|
43
|
+
- Colors are redefined in `prefers-color-scheme: dark`
|
|
44
|
+
- Values are adjusted for optimal contrast in both modes
|
|
45
|
+
- The system maintains visual hierarchy in light and dark
|
|
46
|
+
|
|
47
|
+
### 5. Scale Consistency
|
|
48
|
+
|
|
49
|
+
Both spacing and typography use consistent scales:
|
|
50
|
+
|
|
51
|
+
- Spacing: 4px base unit (0.25rem)
|
|
52
|
+
- Typography: Modular scale with clear relationships
|
|
53
|
+
|
|
54
|
+
## Token Categories
|
|
55
|
+
|
|
56
|
+
### Typography
|
|
57
|
+
|
|
58
|
+
- **Font Families**: System fonts with web-safe fallbacks
|
|
59
|
+
- **Weights**: Named weights from regular to bold
|
|
60
|
+
- **Sizes**: Modular scale from xs (12px) to 4xl (36px)
|
|
61
|
+
|
|
62
|
+
### Spacing
|
|
63
|
+
|
|
64
|
+
- **Size Scale**: 4px increments from 4px to 96px
|
|
65
|
+
- Named by pixel value for clarity (`--size-16` = 1rem = 16px)
|
|
66
|
+
|
|
67
|
+
### Colors
|
|
68
|
+
|
|
69
|
+
- **Surfaces**: Background colors for different elevation levels
|
|
70
|
+
- **Text**: Primary, muted, and inverted text colors
|
|
71
|
+
- **Brand**: Logo-specific colors
|
|
72
|
+
- **Interactive**: Primary and accent colors with hover states
|
|
73
|
+
- **Semantic**: Success, error, warning, info states
|
|
74
|
+
- **Borders**: Subtle and strong border options
|
|
75
|
+
|
|
76
|
+
### Layout
|
|
77
|
+
|
|
78
|
+
- **Border Radius**: Five levels from small to full circle
|
|
79
|
+
- **Z-index**: Named layers for predictable stacking
|
|
80
|
+
- **Transitions**: Three timing options (fast, base, slow)
|
|
81
|
+
|
|
82
|
+
## Usage Examples
|
|
83
|
+
|
|
84
|
+
```css
|
|
85
|
+
/* Typography */
|
|
86
|
+
.heading {
|
|
87
|
+
font-family: var(--font-family-base);
|
|
88
|
+
font-size: var(--text-2xl);
|
|
89
|
+
font-weight: var(--font-weight-bold);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Spacing */
|
|
93
|
+
.card {
|
|
94
|
+
padding: var(--size-24);
|
|
95
|
+
margin-block-end: var(--size-32);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* Colors */
|
|
99
|
+
.button {
|
|
100
|
+
background-color: var(--color-primary);
|
|
101
|
+
color: var(--color-text-inverted);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.button:hover {
|
|
105
|
+
background-color: var(--color-primary-hover);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* Layout */
|
|
109
|
+
.modal {
|
|
110
|
+
border-radius: var(--radius-lg);
|
|
111
|
+
z-index: var(--layer-modal);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Customization Guide
|
|
116
|
+
|
|
117
|
+
### When to Keep as-is
|
|
118
|
+
|
|
119
|
+
- Working on a prototype or MVP
|
|
120
|
+
- Building internal tools where brand consistency isn't critical
|
|
121
|
+
- Learning design systems
|
|
122
|
+
- Quick experiments or proof-of-concepts
|
|
123
|
+
|
|
124
|
+
### When to Customize
|
|
125
|
+
|
|
126
|
+
- Matching specific brand guidelines
|
|
127
|
+
- Projects with unique visual requirements
|
|
128
|
+
- Integrating with existing design systems
|
|
129
|
+
- Production applications with defined visual identity
|
|
130
|
+
|
|
131
|
+
**Remember**: The token _structure_ (semantic naming, scale consistency, system thinking) is more valuable than the specific values. Customize the values to fit your needs, but maintain the systematic approach.
|
|
132
|
+
|
|
133
|
+
## Extending the System
|
|
134
|
+
|
|
135
|
+
These tokens provide a foundation. Projects can:
|
|
136
|
+
|
|
137
|
+
- Add component-specific tokens that reference these base tokens
|
|
138
|
+
- Create semantic aliases (e.g., `--button-bg: var(--color-primary)`)
|
|
139
|
+
- Extend the color palette while maintaining the `oklch()` approach
|
|
140
|
+
- Add new token categories (shadows, animations, grid systems, etc.)
|
|
141
|
+
|
|
142
|
+
The key is maintaining the system's consistency and semantic approach.
|
|
143
|
+
|
|
144
|
+
## Browser Support
|
|
145
|
+
|
|
146
|
+
The `oklch()` color space is supported in:
|
|
147
|
+
|
|
148
|
+
- Chrome/Edge 111+
|
|
149
|
+
- Safari 15.4+
|
|
150
|
+
- Firefox 113+
|
|
151
|
+
|
|
152
|
+
For older browsers, consider using a PostCSS plugin to generate fallback colors, or use this as a progressive enhancement where supported browsers get optimal color fidelity.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: css-tokens
|
|
3
|
+
description: Provides foundational CSS design tokens (custom properties) for typography, spacing, colors, borders, z-index, and transitions. Use when setting up a base token system for a web project.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CSS Design Tokens Skill
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
This skill provides a comprehensive set of CSS design tokens (custom properties) to establish a consistent design foundation for web projects. Use this skill when the user requests a base token system or design tokens for their CSS.
|
|
11
|
+
|
|
12
|
+
## When to Use This Skill
|
|
13
|
+
|
|
14
|
+
Use this skill when the user asks for:
|
|
15
|
+
|
|
16
|
+
- "Add design tokens to my project"
|
|
17
|
+
- "Set up CSS tokens"
|
|
18
|
+
- "Create a tokens file"
|
|
19
|
+
- "Add base CSS variables"
|
|
20
|
+
- Similar requests for foundational CSS custom properties
|
|
21
|
+
|
|
22
|
+
## When NOT to Use This Skill
|
|
23
|
+
|
|
24
|
+
- User already has an existing design token system (suggest modifications instead)
|
|
25
|
+
- User specifically requests a framework-specific token system (e.g., Tailwind config, CSS-in-JS tokens)
|
|
26
|
+
- User only needs a subset of tokens (offer to extract specific categories)
|
|
27
|
+
|
|
28
|
+
## What This Skill Provides
|
|
29
|
+
|
|
30
|
+
A complete `tokens.css` file with a comprehensive design token system:
|
|
31
|
+
|
|
32
|
+
- **Typography**: Font families, weights, and a modular size scale (xs to 4xl)
|
|
33
|
+
- **Spacing**: Consistent size scale from 4px to 96px, named by pixel value
|
|
34
|
+
- **Colors**: Using `oklch()` color space for perceptually uniform colors with light/dark mode variants for surfaces, text, brand, interactive elements, and semantic states
|
|
35
|
+
- **Borders**: Radius values derived from the size scale (sm to full)
|
|
36
|
+
- **Z-index**: Named layers for stacking context (dropdown, modal, toast, etc.)
|
|
37
|
+
- **Transitions**: Standard timing values (fast, base, slow)
|
|
38
|
+
|
|
39
|
+
Users can reference individual tokens using CSS custom property syntax: `var(--token-name)`
|
|
40
|
+
|
|
41
|
+
## Token Content
|
|
42
|
+
|
|
43
|
+
The complete token definitions are located in `references/tokens.css` within this skill directory. This file contains all the CSS custom property declarations organized by category.
|
|
44
|
+
|
|
45
|
+
## How to Use This Skill
|
|
46
|
+
|
|
47
|
+
### 1. Detect CSS Directory
|
|
48
|
+
|
|
49
|
+
Search the project for common CSS directory names:
|
|
50
|
+
|
|
51
|
+
- `css/`
|
|
52
|
+
- `styles/`
|
|
53
|
+
- `assets/css/`
|
|
54
|
+
- `stylesheets/`
|
|
55
|
+
- `src/css/`
|
|
56
|
+
- `src/styles/`
|
|
57
|
+
|
|
58
|
+
Check directories at multiple levels (root, `src/`, `public/`, `assets/`).
|
|
59
|
+
|
|
60
|
+
### 2. Confirm Location with User
|
|
61
|
+
|
|
62
|
+
**If a CSS directory is found:**
|
|
63
|
+
|
|
64
|
+
Present the discovered location and ask for confirmation:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
I found a CSS directory at [path]. Should I add the design tokens to this directory in a file named `tokens.css`?
|
|
68
|
+
|
|
69
|
+
If you'd like a different location or filename, please specify both.
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**If no CSS directory is found:**
|
|
73
|
+
|
|
74
|
+
Ask the user directly:
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
I couldn't find an existing CSS directory in your project. Please specify:
|
|
78
|
+
1. The directory path where you'd like the tokens file (I can create it if needed)
|
|
79
|
+
2. The filename (e.g., `tokens.css`, `design-tokens.css`)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 3. Write the Tokens File
|
|
83
|
+
|
|
84
|
+
Once confirmed, write the complete tokens file to the specified location. Use the exact content from `references/tokens.css` in this skill directory.
|
|
85
|
+
|
|
86
|
+
### 4. Inform User About Import
|
|
87
|
+
|
|
88
|
+
After successfully writing the file, inform the user:
|
|
89
|
+
|
|
90
|
+
✓ Design tokens written to [full-path]
|
|
91
|
+
|
|
92
|
+
To use these tokens in your project, import this file in your main CSS file or HTML:
|
|
93
|
+
|
|
94
|
+
**In CSS:**
|
|
95
|
+
|
|
96
|
+
```css
|
|
97
|
+
@import url('path/to/tokens.css');
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**In HTML:**
|
|
101
|
+
|
|
102
|
+
```html
|
|
103
|
+
<link rel="stylesheet" href="path/to/tokens.css" />
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The tokens are now available as CSS custom properties throughout your project (e.g., `var(--color-primary)`, `var(--size-16)`).
|
|
107
|
+
|
|
108
|
+
## Customization
|
|
109
|
+
|
|
110
|
+
These tokens provide a solid foundation but are meant to be customized for your project:
|
|
111
|
+
|
|
112
|
+
- Adjust color values to match your brand
|
|
113
|
+
- Modify the spacing scale to fit your design system
|
|
114
|
+
- Add project-specific tokens as needed
|
|
115
|
+
- Extend categories with additional tokens (animations, shadows, etc.)
|
|
116
|
+
|
|
117
|
+
This is a **scaffolding skill** - it sets up the initial structure but doesn't handle ongoing modifications.
|
|
118
|
+
|
|
119
|
+
## Important Notes
|
|
120
|
+
|
|
121
|
+
- **Do NOT make assumptions** about directory structure or filename if the user hasn't specified
|
|
122
|
+
- **Always confirm** the location before writing
|
|
123
|
+
- **Create directories** if needed and confirmed by user
|
|
124
|
+
- The tokens file includes both light and dark mode color schemes using `prefers-color-scheme`
|
|
125
|
+
- The `oklch()` color space provides perceptually uniform colors for better accessibility and consistency
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
/* ========================================
|
|
3
|
+
* Typography - Font Families
|
|
4
|
+
* ======================================== */
|
|
5
|
+
--font-family-base:
|
|
6
|
+
inter, "Source Sans 3", "IBM Plex Sans", -apple-system, blinkmacsystemfont,
|
|
7
|
+
"Segoe UI", roboto, helvetica, arial, sans-serif;
|
|
8
|
+
--font-family-mono:
|
|
9
|
+
ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono",
|
|
10
|
+
"Liberation Mono", menlo, monaco, consolas, monospace;
|
|
11
|
+
|
|
12
|
+
/* ========================================
|
|
13
|
+
* Typography - Font Weights
|
|
14
|
+
* ======================================== */
|
|
15
|
+
--font-weight-regular: 400;
|
|
16
|
+
--font-weight-medium: 500;
|
|
17
|
+
--font-weight-semibold: 600;
|
|
18
|
+
--font-weight-bold: 700;
|
|
19
|
+
|
|
20
|
+
/* ========================================
|
|
21
|
+
* Typography - Font Sizes
|
|
22
|
+
* Token name = approximate pixel value
|
|
23
|
+
* ======================================== */
|
|
24
|
+
--text-xs: 0.75rem; /* 12px */
|
|
25
|
+
--text-sm: 0.875rem; /* 14px */
|
|
26
|
+
--text-base: 1rem; /* 16px */
|
|
27
|
+
--text-lg: 1.125rem; /* 18px */
|
|
28
|
+
--text-xl: 1.25rem; /* 20px */
|
|
29
|
+
--text-2xl: 1.5rem; /* 24px */
|
|
30
|
+
--text-3xl: 1.875rem; /* 30px */
|
|
31
|
+
--text-4xl: 2.25rem; /* 36px */
|
|
32
|
+
|
|
33
|
+
/* ========================================
|
|
34
|
+
* Spacing / Size Scale
|
|
35
|
+
* Token name = pixel value (--size-16 = 16px = 1rem)
|
|
36
|
+
* ======================================== */
|
|
37
|
+
--size-4: 0.25rem; /* 4px */
|
|
38
|
+
--size-8: 0.5rem; /* 8px */
|
|
39
|
+
--size-12: 0.75rem; /* 12px */
|
|
40
|
+
--size-16: 1rem; /* 16px */
|
|
41
|
+
--size-20: 1.25rem; /* 20px */
|
|
42
|
+
--size-24: 1.5rem; /* 24px */
|
|
43
|
+
--size-32: 2rem; /* 32px */
|
|
44
|
+
--size-40: 2.5rem; /* 40px */
|
|
45
|
+
--size-48: 3rem; /* 48px */
|
|
46
|
+
--size-64: 4rem; /* 64px */
|
|
47
|
+
--size-80: 5rem; /* 80px */
|
|
48
|
+
--size-96: 6rem; /* 96px */
|
|
49
|
+
|
|
50
|
+
/* ========================================
|
|
51
|
+
* Border Radius (uses size tokens)
|
|
52
|
+
* ======================================== */
|
|
53
|
+
--radius-sm: var(--size-4);
|
|
54
|
+
--radius-md: var(--size-8);
|
|
55
|
+
--radius-lg: var(--size-12);
|
|
56
|
+
--radius-xl: var(--size-16);
|
|
57
|
+
--radius-full: 50%;
|
|
58
|
+
|
|
59
|
+
/* ========================================
|
|
60
|
+
* Z-Index Layers
|
|
61
|
+
* ======================================== */
|
|
62
|
+
--layer-send-to-back: -1;
|
|
63
|
+
--layer-dropdown: 100;
|
|
64
|
+
--layer-modal: 300;
|
|
65
|
+
--layer-toast: 400;
|
|
66
|
+
--layer-bring-to-front: 9999;
|
|
67
|
+
|
|
68
|
+
/* ========================================
|
|
69
|
+
* Transitions
|
|
70
|
+
* ======================================== */
|
|
71
|
+
--transition-fast: 150ms ease;
|
|
72
|
+
--transition-base: 250ms ease;
|
|
73
|
+
--transition-slow: 400ms ease;
|
|
74
|
+
|
|
75
|
+
/* ========================================
|
|
76
|
+
* Colors - Light Mode (Default)
|
|
77
|
+
* Using oklch() for perceptual uniformity
|
|
78
|
+
* ======================================== */
|
|
79
|
+
|
|
80
|
+
/* Surfaces */
|
|
81
|
+
--color-surface: oklch(98% 0.005 250deg); /* Near white */
|
|
82
|
+
--color-surface-raised: oklch(100% 0 0deg); /* Pure white */
|
|
83
|
+
--color-surface-sunken: oklch(95% 0.01 250deg); /* Slightly darker */
|
|
84
|
+
|
|
85
|
+
/* Text */
|
|
86
|
+
--color-text: oklch(25% 0.02 250deg); /* Dark slate */
|
|
87
|
+
--color-text-muted: oklch(50% 0.015 250deg); /* Medium gray */
|
|
88
|
+
--color-text-inverted: oklch(
|
|
89
|
+
98% 0.005 250deg
|
|
90
|
+
); /* Light for dark backgrounds */
|
|
91
|
+
|
|
92
|
+
/* Logo Colors - derived from brand */
|
|
93
|
+
--color-logo-maker: oklch(40% 0.025 220deg); /* Dark slate-blue */
|
|
94
|
+
--color-logo-bench: oklch(55% 0.15 185deg); /* Teal */
|
|
95
|
+
|
|
96
|
+
/* Primary - Teal (matches logo "Bench") */
|
|
97
|
+
--color-primary: oklch(50% 0.14 185deg);
|
|
98
|
+
--color-primary-hover: oklch(45% 0.14 185deg);
|
|
99
|
+
--color-primary-active: oklch(40% 0.14 185deg);
|
|
100
|
+
|
|
101
|
+
/* Accent - Coral/Orange for CTAs */
|
|
102
|
+
--color-accent: oklch(65% 0.18 35deg);
|
|
103
|
+
--color-accent-hover: oklch(60% 0.18 35deg);
|
|
104
|
+
|
|
105
|
+
/* Borders */
|
|
106
|
+
--color-border: oklch(88% 0.01 250deg);
|
|
107
|
+
--color-border-strong: oklch(75% 0.015 250deg);
|
|
108
|
+
|
|
109
|
+
/* States */
|
|
110
|
+
--color-success: oklch(55% 0.15 145deg);
|
|
111
|
+
--color-error: oklch(55% 0.2 25deg);
|
|
112
|
+
--color-warning: oklch(70% 0.15 80deg);
|
|
113
|
+
--color-info: oklch(55% 0.12 240deg);
|
|
114
|
+
|
|
115
|
+
/* Focus ring */
|
|
116
|
+
--color-focus-ring: oklch(55% 0.15 185deg / 50%);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* ========================================
|
|
120
|
+
* Colors - Dark Mode
|
|
121
|
+
* ======================================== */
|
|
122
|
+
@media (prefers-color-scheme: dark) {
|
|
123
|
+
:root {
|
|
124
|
+
/* Surfaces */
|
|
125
|
+
--color-surface: oklch(18% 0.015 250deg); /* Deep charcoal */
|
|
126
|
+
--color-surface-raised: oklch(22% 0.015 250deg); /* Elevated dark */
|
|
127
|
+
--color-surface-sunken: oklch(14% 0.015 250deg); /* Deeper */
|
|
128
|
+
|
|
129
|
+
/* Text */
|
|
130
|
+
--color-text: oklch(92% 0.01 250deg); /* Light gray */
|
|
131
|
+
--color-text-muted: oklch(65% 0.01 250deg); /* Muted gray */
|
|
132
|
+
--color-text-inverted: oklch(
|
|
133
|
+
18% 0.015 250deg
|
|
134
|
+
); /* Dark for light backgrounds */
|
|
135
|
+
|
|
136
|
+
/* Logo Colors - brighter for dark mode */
|
|
137
|
+
--color-logo-maker: oklch(75% 0.02 220deg); /* Lighter slate */
|
|
138
|
+
--color-logo-bench: oklch(65% 0.15 185deg); /* Brighter teal */
|
|
139
|
+
|
|
140
|
+
/* Primary - Brighter teal for dark mode */
|
|
141
|
+
--color-primary: oklch(60% 0.14 185deg);
|
|
142
|
+
--color-primary-hover: oklch(65% 0.14 185deg);
|
|
143
|
+
--color-primary-active: oklch(55% 0.14 185deg);
|
|
144
|
+
|
|
145
|
+
/* Accent */
|
|
146
|
+
--color-accent: oklch(70% 0.16 35deg);
|
|
147
|
+
--color-accent-hover: oklch(75% 0.16 35deg);
|
|
148
|
+
|
|
149
|
+
/* Borders */
|
|
150
|
+
--color-border: oklch(30% 0.015 250deg);
|
|
151
|
+
--color-border-strong: oklch(40% 0.015 250deg);
|
|
152
|
+
|
|
153
|
+
/* States */
|
|
154
|
+
--color-success: oklch(60% 0.15 145deg);
|
|
155
|
+
--color-error: oklch(60% 0.18 25deg);
|
|
156
|
+
--color-warning: oklch(75% 0.15 80deg);
|
|
157
|
+
--color-info: oklch(60% 0.12 240deg);
|
|
158
|
+
|
|
159
|
+
/* Focus ring */
|
|
160
|
+
--color-focus-ring: oklch(60% 0.15 185deg / 50%);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: frontend-security
|
|
3
|
+
description: Audit frontend codebases for security vulnerabilities and bad practices. Use when performing security reviews, auditing code for XSS/CSRF/DOM vulnerabilities, checking Content Security Policy configurations, validating input handling, reviewing file upload security, or examining Node.js/NPM dependencies. Target frameworks include web platform (vanilla HTML/CSS/JS), React, Astro, Twig templates, Node.js, and Bun. Based on OWASP security guidelines.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Frontend Security Audit Skill
|
|
7
|
+
|
|
8
|
+
Perform comprehensive security audits of frontend codebases to identify vulnerabilities, bad practices, and missing protections.
|
|
9
|
+
|
|
10
|
+
## Audit Process
|
|
11
|
+
|
|
12
|
+
1. **Scan for dangerous patterns** - Search codebase for known vulnerability indicators
|
|
13
|
+
2. **Review framework-specific risks** - Check for framework security bypass patterns
|
|
14
|
+
3. **Validate defensive measures** - Verify CSP, CSRF tokens, input validation
|
|
15
|
+
4. **Check dependencies** - Review npm/node dependencies for vulnerabilities
|
|
16
|
+
5. **Report findings** - Categorize by severity with remediation guidance
|
|
17
|
+
|
|
18
|
+
## Critical Vulnerability Patterns to Search
|
|
19
|
+
|
|
20
|
+
### XSS Indicators (Search Priority: HIGH)
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# React dangerous patterns
|
|
24
|
+
grep -rn "dangerouslySetInnerHTML" --include="*.jsx" --include="*.tsx" --include="*.js"
|
|
25
|
+
|
|
26
|
+
# Direct DOM manipulation
|
|
27
|
+
grep -rn "\.innerHTML\s*=" --include="*.js" --include="*.ts" --include="*.jsx" --include="*.tsx"
|
|
28
|
+
grep -rn "\.outerHTML\s*=" --include="*.js" --include="*.ts"
|
|
29
|
+
grep -rn "document\.write" --include="*.js" --include="*.ts"
|
|
30
|
+
|
|
31
|
+
# URL-based injection
|
|
32
|
+
grep -rn "location\.href\s*=" --include="*.js" --include="*.ts"
|
|
33
|
+
grep -rn "location\.replace" --include="*.js" --include="*.ts"
|
|
34
|
+
grep -rn "window\.open" --include="*.js" --include="*.ts"
|
|
35
|
+
|
|
36
|
+
# Eval and code execution
|
|
37
|
+
grep -rn "eval\s*(" --include="*.js" --include="*.ts"
|
|
38
|
+
grep -rn "new Function\s*(" --include="*.js" --include="*.ts"
|
|
39
|
+
grep -rn "setTimeout\s*(\s*['\"]" --include="*.js" --include="*.ts"
|
|
40
|
+
grep -rn "setInterval\s*(\s*['\"]" --include="*.js" --include="*.ts"
|
|
41
|
+
|
|
42
|
+
# Twig unescaped output
|
|
43
|
+
grep -rn "|raw" --include="*.twig" --include="*.html.twig"
|
|
44
|
+
grep -rn "{% autoescape false %}" --include="*.twig"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### CSRF Indicators
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Forms without CSRF tokens
|
|
51
|
+
grep -rn "<form" --include="*.html" --include="*.jsx" --include="*.tsx" --include="*.twig"
|
|
52
|
+
|
|
53
|
+
# State-changing requests without protection
|
|
54
|
+
grep -rn "fetch\s*(" --include="*.js" --include="*.ts" | grep -E "(POST|PUT|DELETE|PATCH)"
|
|
55
|
+
grep -rn "axios\.(post|put|delete|patch)" --include="*.js" --include="*.ts"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Sensitive Data Exposure
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# localStorage/sessionStorage with sensitive data
|
|
62
|
+
grep -rn "localStorage\." --include="*.js" --include="*.ts"
|
|
63
|
+
grep -rn "sessionStorage\." --include="*.js" --include="*.ts"
|
|
64
|
+
|
|
65
|
+
# Hardcoded secrets
|
|
66
|
+
grep -rn "api[_-]?key\s*[:=]" --include="*.js" --include="*.ts" --include="*.env"
|
|
67
|
+
grep -rn "secret\s*[:=]" --include="*.js" --include="*.ts"
|
|
68
|
+
grep -rn "password\s*[:=]" --include="*.js" --include="*.ts"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Reference Documentation
|
|
72
|
+
|
|
73
|
+
Load these references based on findings:
|
|
74
|
+
|
|
75
|
+
- **XSS vulnerabilities found**: See `references/xss-prevention.md`
|
|
76
|
+
- **CSRF concerns**: See `references/csrf-protection.md`
|
|
77
|
+
- **DOM manipulation issues**: See `references/dom-security.md`
|
|
78
|
+
- **CSP review needed**: See `references/csp-configuration.md`
|
|
79
|
+
- **Input handling issues**: See `references/input-validation.md`
|
|
80
|
+
- **Node.js/NPM audit**: See `references/nodejs-npm-security.md`
|
|
81
|
+
- **Framework-specific patterns**: See `references/framework-patterns.md`
|
|
82
|
+
- **File upload handling**: See `references/file-upload-security.md`
|
|
83
|
+
- **JWT implementation**: See `references/jwt-security.md`
|
|
84
|
+
|
|
85
|
+
## Severity Classification
|
|
86
|
+
|
|
87
|
+
**CRITICAL** - Exploitable XSS, authentication bypass, secrets exposure
|
|
88
|
+
**HIGH** - Missing CSRF protection, unsafe DOM manipulation, SQL injection vectors
|
|
89
|
+
**MEDIUM** - Weak CSP, missing security headers, improper input validation
|
|
90
|
+
**LOW** - Informational disclosure, deprecated functions, suboptimal practices
|
|
91
|
+
|
|
92
|
+
## Report Format
|
|
93
|
+
|
|
94
|
+
```markdown
|
|
95
|
+
## Security Audit Report
|
|
96
|
+
|
|
97
|
+
### Summary
|
|
98
|
+
- Critical: X findings
|
|
99
|
+
- High: X findings
|
|
100
|
+
- Medium: X findings
|
|
101
|
+
- Low: X findings
|
|
102
|
+
|
|
103
|
+
### Critical Findings
|
|
104
|
+
|
|
105
|
+
#### [CRITICAL-001] Title
|
|
106
|
+
- **Location**: file:line
|
|
107
|
+
- **Pattern**: Code snippet
|
|
108
|
+
- **Risk**: Description of the vulnerability
|
|
109
|
+
- **Remediation**: How to fix
|
|
110
|
+
- **Reference**: OWASP link
|
|
111
|
+
|
|
112
|
+
### High Findings
|
|
113
|
+
[...]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## OWASP Reference Links
|
|
117
|
+
|
|
118
|
+
For comprehensive guidance, consult these OWASP cheatsheets directly:
|
|
119
|
+
|
|
120
|
+
- XSS Prevention: https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
|
|
121
|
+
- DOM XSS Prevention: https://cheatsheetseries.owasp.org/cheatsheets/DOM_based_XSS_Prevention_Cheat_Sheet.html
|
|
122
|
+
- CSRF Prevention: https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html
|
|
123
|
+
- CSP: https://cheatsheetseries.owasp.org/cheatsheets/Content_Security_Policy_Cheat_Sheet.html
|
|
124
|
+
- Input Validation: https://cheatsheetseries.owasp.org/cheatsheets/Input_Validation_Cheat_Sheet.html
|
|
125
|
+
- HTML5 Security: https://cheatsheetseries.owasp.org/cheatsheets/HTML5_Security_Cheat_Sheet.html
|
|
126
|
+
- DOM Clobbering: https://cheatsheetseries.owasp.org/cheatsheets/DOM_Clobbering_Prevention_Cheat_Sheet.html
|
|
127
|
+
- Node.js Security: https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html
|
|
128
|
+
- NPM Security: https://cheatsheetseries.owasp.org/cheatsheets/NPM_Security_Cheat_Sheet.html
|
|
129
|
+
- AJAX Security: https://cheatsheetseries.owasp.org/cheatsheets/AJAX_Security_Cheat_Sheet.html
|
|
130
|
+
- File Upload: https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html
|
|
131
|
+
- Error Handling: https://cheatsheetseries.owasp.org/cheatsheets/Error_Handling_Cheat_Sheet.html
|
|
132
|
+
- JWT Security: https://cheatsheetseries.owasp.org/cheatsheets/JSON_Web_Token_for_Java_Cheat_Sheet.html
|
|
133
|
+
- User Privacy: https://cheatsheetseries.owasp.org/cheatsheets/User_Privacy_Protection_Cheat_Sheet.html
|
|
134
|
+
- gRPC Security: https://cheatsheetseries.owasp.org/cheatsheets/gRPC_Security_Cheat_Sheet.html
|