agents-templated 2.2.0 → 2.2.2
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 +9 -9
- package/bin/cli.js +9 -9
- package/index.js +12 -1
- package/lib/instructions.js +20 -6
- package/lib/layout.js +3 -2
- package/package.json +1 -1
- package/templates/{agents/subagents → .claude/agents}/README.md +2 -2
- package/templates/.claude/rules/ai-integration.mdc +60 -0
- package/templates/.claude/rules/core.mdc +180 -0
- package/templates/.claude/rules/database.mdc +291 -0
- package/templates/.claude/rules/frontend.mdc +224 -0
- package/templates/.claude/rules/guardrails.mdc +105 -0
- package/templates/.claude/rules/hardening.mdc +58 -0
- package/templates/.claude/rules/intent-routing.mdc +59 -0
- package/templates/.claude/rules/planning.mdc +75 -0
- package/templates/.claude/rules/security.mdc +286 -0
- package/templates/.claude/rules/style.mdc +306 -0
- package/templates/.claude/rules/system-workflow.mdc +69 -0
- package/templates/.claude/rules/testing.mdc +308 -0
- package/templates/.claude/rules/workflows.mdc +61 -0
- package/templates/.cursorrules +2 -5
- package/templates/CLAUDE.md +37 -37
- package/templates/README.md +3 -3
- package/templates/agent-docs/ARCHITECTURE.md +3 -3
- package/templates/agent-docs/README.md +12 -13
- package/templates/agents/rules/ai-integration.mdc +10 -2
- package/templates/agents/rules/core.mdc +8 -1
- package/templates/agents/rules/database.mdc +10 -2
- package/templates/agents/rules/frontend.mdc +10 -2
- package/templates/agents/rules/guardrails.mdc +10 -2
- package/templates/agents/rules/hardening.mdc +10 -2
- package/templates/agents/rules/intent-routing.mdc +10 -2
- package/templates/agents/rules/planning.mdc +10 -2
- package/templates/agents/rules/security.mdc +11 -2
- package/templates/agents/rules/style.mdc +10 -2
- package/templates/agents/rules/system-workflow.mdc +10 -2
- package/templates/agents/rules/testing.mdc +9 -1
- package/templates/agents/rules/workflows.mdc +10 -2
- package/templates/agents/skills/README.md +6 -6
- package/templates/instructions/source/core.md +0 -219
- /package/templates/{agents/subagents → .claude/agents}/architect.md +0 -0
- /package/templates/{agents/subagents → .claude/agents}/build-error-resolver.md +0 -0
- /package/templates/{agents/subagents → .claude/agents}/code-reviewer.md +0 -0
- /package/templates/{agents/subagents → .claude/agents}/doc-updater.md +0 -0
- /package/templates/{agents/subagents → .claude/agents}/e2e-runner.md +0 -0
- /package/templates/{agents/subagents → .claude/agents}/planner.md +0 -0
- /package/templates/{agents/subagents → .claude/agents}/refactor-cleaner.md +0 -0
- /package/templates/{agents/subagents → .claude/agents}/security-reviewer.md +0 -0
- /package/templates/{agents/subagents → .claude/agents}/tdd-guide.md +0 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Database and Data Layer Guidelines"
|
|
3
|
+
description: "Apply when designing schema, building data access layers, running migrations, or optimizing queries"
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
version: "3.0.0"
|
|
6
|
+
tags: ["database", "backend", "data", "orm", "schema"]
|
|
7
|
+
globs:
|
|
8
|
+
- "src/models/**/*"
|
|
9
|
+
- "src/data/**/*"
|
|
10
|
+
triggers:
|
|
11
|
+
- "Designing database schema or tables"
|
|
12
|
+
- "Creating/updating ORM models or queries"
|
|
13
|
+
- "Running database migrations"
|
|
14
|
+
- "Optimizing slow queries"
|
|
15
|
+
- "Selecting database technology"
|
|
16
|
+
- "Implementing access control for data"
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# Database and Data Layer Guidelines
|
|
20
|
+
|
|
21
|
+
Technology-agnostic patterns for secure, maintainable data access.
|
|
22
|
+
|
|
23
|
+
## Core Principles
|
|
24
|
+
|
|
25
|
+
### Design First
|
|
26
|
+
- **Schema design** - Think through relationships and constraints
|
|
27
|
+
- **Normalization** - Minimize data duplication and anomalies
|
|
28
|
+
- **Scalability** - Design for growth and performance
|
|
29
|
+
- **Consistency** - ACID transactions when needed (SQL) or eventual consistency patterns (NoSQL)
|
|
30
|
+
- **Security** - Access controls at database and application level
|
|
31
|
+
|
|
32
|
+
### Access Patterns
|
|
33
|
+
- **ORM/ODM only** - Use abstraction layer, never raw SQL/queries
|
|
34
|
+
- **Parameterized queries** - Prevent injection attacks
|
|
35
|
+
- **Query optimization** - Avoid N+1 problems and slow queries
|
|
36
|
+
- **Connection pooling** - Manage resources efficiently
|
|
37
|
+
- **Error handling** - Graceful degradation when database unavailable
|
|
38
|
+
|
|
39
|
+
### Migration Strategy
|
|
40
|
+
- **Version control** - All schema changes tracked
|
|
41
|
+
- **Idempotent migrations** - Can run multiple times safely
|
|
42
|
+
- **Reversible migrations** - Can rollback if needed
|
|
43
|
+
- **Testing** - Test migrations in all environments
|
|
44
|
+
- **Documentation** - Document significant schema decisions
|
|
45
|
+
|
|
46
|
+
## Database Strategy Options
|
|
47
|
+
|
|
48
|
+
### SQL Databases (PostgreSQL, MySQL, SQLite, SQL Server)
|
|
49
|
+
|
|
50
|
+
Characteristics:
|
|
51
|
+
- Structured schema with defined tables and relationships
|
|
52
|
+
- ACID transactions for data consistency
|
|
53
|
+
- Powerful querying with SQL
|
|
54
|
+
- Good for relational data
|
|
55
|
+
- Mature tooling and libraries
|
|
56
|
+
|
|
57
|
+
Tools:
|
|
58
|
+
- ORM: Sequelize (Node.js), SQLAlchemy (Python), Hibernate (Java), Entity Framework (.NET)
|
|
59
|
+
- Query Builder: Knex.js (Node.js), SqlAlchemy Core (Python), QueryDSL (Java)
|
|
60
|
+
- Migration tools: Prisma Migrate, Flyway, Liquibase, Alembic
|
|
61
|
+
|
|
62
|
+
Best for:
|
|
63
|
+
- Complex relationships between entities
|
|
64
|
+
- Strong consistency requirements
|
|
65
|
+
- Transactional integrity
|
|
66
|
+
- Complex queries
|
|
67
|
+
- Team comfortable with SQL
|
|
68
|
+
|
|
69
|
+
### NoSQL Databases (MongoDB, DynamoDB, CouchDB, Firestore)
|
|
70
|
+
|
|
71
|
+
Characteristics:
|
|
72
|
+
- Flexible/schemaless documents
|
|
73
|
+
- Eventual consistency
|
|
74
|
+
- Good horizontal scaling
|
|
75
|
+
- Fast for simple lookups
|
|
76
|
+
- Dev-friendly for rapid iteration
|
|
77
|
+
|
|
78
|
+
Tools:
|
|
79
|
+
- ODM: Mongoose (MongoDB), AWS SDK (DynamoDB), Firebase SDK (Firestore)
|
|
80
|
+
- Schema validation: JSONSchema, Zod, Joi
|
|
81
|
+
|
|
82
|
+
Best for:
|
|
83
|
+
- Flexible/evolving data structures
|
|
84
|
+
- Horizontal scaling
|
|
85
|
+
- Fast document lookups
|
|
86
|
+
- Real-time updates
|
|
87
|
+
- Prototyping and MVPs
|
|
88
|
+
|
|
89
|
+
### Managed Database Services (Supabase, Firebase, AWS RDS)
|
|
90
|
+
|
|
91
|
+
Characteristics:
|
|
92
|
+
- Hosted by cloud provider
|
|
93
|
+
- Automatic backups and scaling
|
|
94
|
+
- Built-in authentication
|
|
95
|
+
- Real-time subscriptions (some)
|
|
96
|
+
- Reduced infrastructure complexity
|
|
97
|
+
|
|
98
|
+
Best for:
|
|
99
|
+
- Rapid prototyping
|
|
100
|
+
- Teams without DevOps expertise
|
|
101
|
+
- Projects needing built-in features
|
|
102
|
+
- Compliance-heavy requirements
|
|
103
|
+
- Teams preferring managed services
|
|
104
|
+
|
|
105
|
+
## Schema Design Patterns
|
|
106
|
+
|
|
107
|
+
### Core Tables/Collections
|
|
108
|
+
|
|
109
|
+
Base entities:
|
|
110
|
+
- **Users**: Authentication and identity data
|
|
111
|
+
- **Roles**: Permission groups
|
|
112
|
+
- **Audit logs**: Track changes for compliance
|
|
113
|
+
|
|
114
|
+
Related data:
|
|
115
|
+
- Define relationships clearly
|
|
116
|
+
- Use appropriate constraints (foreign keys, unique constraints)
|
|
117
|
+
- Add indexes for common queries
|
|
118
|
+
- Document connection between tables
|
|
119
|
+
|
|
120
|
+
### Timestamps
|
|
121
|
+
|
|
122
|
+
Include timestamps:
|
|
123
|
+
- **Created at**: When record created (immutable)
|
|
124
|
+
- **Updated at**: When record last modified
|
|
125
|
+
- **Deleted at**: For soft deletes (when applicable)
|
|
126
|
+
|
|
127
|
+
### IDs and Keys
|
|
128
|
+
|
|
129
|
+
ID strategy:
|
|
130
|
+
- **Primary key**: Uniquely identifies record
|
|
131
|
+
- **Foreign key**: References another table (relational)
|
|
132
|
+
- **Unique constraints**: Prevent duplicates
|
|
133
|
+
- **Non-sequential IDs**: Use UUID or similar for security
|
|
134
|
+
|
|
135
|
+
### Data Validation
|
|
136
|
+
|
|
137
|
+
At database level:
|
|
138
|
+
- Required fields (NOT NULL)
|
|
139
|
+
- Data type constraints
|
|
140
|
+
- Length constraints (for strings)
|
|
141
|
+
- Enum constraints (for limited values)
|
|
142
|
+
- Range constraints (for numbers)
|
|
143
|
+
|
|
144
|
+
At application level:
|
|
145
|
+
- Validate before insert/update
|
|
146
|
+
- Validate format (email, URL, etc.)
|
|
147
|
+
- Validate business rules
|
|
148
|
+
- Return clear error messages
|
|
149
|
+
|
|
150
|
+
## Query Patterns
|
|
151
|
+
|
|
152
|
+
### Efficient Queries
|
|
153
|
+
|
|
154
|
+
Do:
|
|
155
|
+
- Use WHERE clauses to filter
|
|
156
|
+
- Use indexes on filtered fields
|
|
157
|
+
- Use SELECT specific columns
|
|
158
|
+
- Use LIMIT for pagination
|
|
159
|
+
- Use JOIN for related data
|
|
160
|
+
- Use aggregation functions
|
|
161
|
+
- Batch operations when possible
|
|
162
|
+
|
|
163
|
+
Don't:
|
|
164
|
+
- SELECT * (select all columns)
|
|
165
|
+
- N+1 queries (query in loop)
|
|
166
|
+
- Unindexed large scans
|
|
167
|
+
- Complex JOINs without indexes
|
|
168
|
+
- Missing WHERE clause
|
|
169
|
+
- Fetching unused data
|
|
170
|
+
|
|
171
|
+
### Pagination
|
|
172
|
+
|
|
173
|
+
Pagination pattern:
|
|
174
|
+
1. Accept limit and offset parameters
|
|
175
|
+
2. Validate reasonable limit (max 100-1000)
|
|
176
|
+
3. Query with LIMIT and OFFSET
|
|
177
|
+
4. Return total count optionally
|
|
178
|
+
5. Include nextPage/previousPage links
|
|
179
|
+
|
|
180
|
+
### Relationships
|
|
181
|
+
|
|
182
|
+
Query related data:
|
|
183
|
+
- One-to-many: JOIN or separate queries
|
|
184
|
+
- Many-to-many: Junction table with JOINs
|
|
185
|
+
- One-to-one: JOIN or embed in document
|
|
186
|
+
- Hierarchical: Recursive queries or denormalization
|
|
187
|
+
|
|
188
|
+
## Security
|
|
189
|
+
|
|
190
|
+
### Access Control
|
|
191
|
+
|
|
192
|
+
Implement at database:
|
|
193
|
+
- Row-level security (RLS in PostgreSQL, Firestore)
|
|
194
|
+
- Column-level access restrictions
|
|
195
|
+
- Database-level user permissions
|
|
196
|
+
|
|
197
|
+
Implement at application:
|
|
198
|
+
- Verify user owns resource before returning
|
|
199
|
+
- Check permissions before allowing modifications
|
|
200
|
+
- Log access to sensitive data
|
|
201
|
+
- Rate limit database operations
|
|
202
|
+
|
|
203
|
+
### Sensitive Data
|
|
204
|
+
|
|
205
|
+
Protect sensitive data:
|
|
206
|
+
- Hash passwords (never store plaintext)
|
|
207
|
+
- Encrypt PII at rest
|
|
208
|
+
- Never log sensitive data
|
|
209
|
+
- Mask sensitive data in backups
|
|
210
|
+
- Use parameterized queries to prevent injection
|
|
211
|
+
|
|
212
|
+
### Backup & Recovery
|
|
213
|
+
|
|
214
|
+
Backup strategy:
|
|
215
|
+
- Automated daily backups
|
|
216
|
+
- Test recovery procedures
|
|
217
|
+
- Retain backups for compliance period
|
|
218
|
+
- Encrypt backups at rest
|
|
219
|
+
- Store backups separately from primary database
|
|
220
|
+
|
|
221
|
+
## Performance
|
|
222
|
+
|
|
223
|
+
### Indexing
|
|
224
|
+
|
|
225
|
+
Index columns that are:
|
|
226
|
+
- Frequently filtered (WHERE clause)
|
|
227
|
+
- Used in JOINs
|
|
228
|
+
- Used in ORDER BY
|
|
229
|
+
- Used in DISTINCT
|
|
230
|
+
|
|
231
|
+
Don't over-index:
|
|
232
|
+
- Too many indexes slow down writes
|
|
233
|
+
- Indexes require storage space
|
|
234
|
+
- Maintain only used indexes
|
|
235
|
+
|
|
236
|
+
### Connection Management
|
|
237
|
+
|
|
238
|
+
Connection pooling:
|
|
239
|
+
- Reuse connections across requests
|
|
240
|
+
- Configure reasonable pool size (10-20 connections)
|
|
241
|
+
- Set idle timeout
|
|
242
|
+
- Monitor connection usage
|
|
243
|
+
- Alert on connection exhaustion
|
|
244
|
+
|
|
245
|
+
### Query Optimization
|
|
246
|
+
|
|
247
|
+
Optimize slow queries:
|
|
248
|
+
1. Profile query execution time
|
|
249
|
+
2. Check execution plan
|
|
250
|
+
3. Add missing indexes
|
|
251
|
+
4. Rewrite queries if needed
|
|
252
|
+
5. Consider denormalization if needed
|
|
253
|
+
6. Verify schema design
|
|
254
|
+
|
|
255
|
+
## Monitoring & Maintenance
|
|
256
|
+
|
|
257
|
+
### Health Checks
|
|
258
|
+
|
|
259
|
+
Monitor:
|
|
260
|
+
- Database connectivity
|
|
261
|
+
- Query performance (slow query logs)
|
|
262
|
+
- Connection pool status
|
|
263
|
+
- Storage space usage
|
|
264
|
+
- Backup completion
|
|
265
|
+
- Replication lag (if applicable)
|
|
266
|
+
|
|
267
|
+
### Database Maintenance
|
|
268
|
+
|
|
269
|
+
Regular tasks:
|
|
270
|
+
- Update statistics/analyze
|
|
271
|
+
- Vacuum/compact (depending on DB)
|
|
272
|
+
- Rebuild indexes if needed
|
|
273
|
+
- Clean up old audit logs
|
|
274
|
+
- Review and optimize slow queries
|
|
275
|
+
|
|
276
|
+
## Testing
|
|
277
|
+
|
|
278
|
+
### Test Data
|
|
279
|
+
|
|
280
|
+
Setup:
|
|
281
|
+
- Use separate test database
|
|
282
|
+
- Reset data before each test
|
|
283
|
+
- Use factories for consistent test data
|
|
284
|
+
- Seed with realistic data
|
|
285
|
+
|
|
286
|
+
Testing patterns:
|
|
287
|
+
- Test CRUD operations
|
|
288
|
+
- Test relationships
|
|
289
|
+
- Test constraints
|
|
290
|
+
- Test error cases
|
|
291
|
+
- Test performance
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Frontend Development Guidelines"
|
|
3
|
+
description: "Apply when building UI components, designing pages, implementing forms, or working with accessibility/responsiveness"
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
version: "3.0.0"
|
|
6
|
+
tags: ["frontend", "ui", "ux", "security", "accessibility"]
|
|
7
|
+
globs:
|
|
8
|
+
- "src/**/*"
|
|
9
|
+
- "components/**/*"
|
|
10
|
+
- "public/**/*"
|
|
11
|
+
triggers:
|
|
12
|
+
- "Building user interfaces or components"
|
|
13
|
+
- "Designing responsive layouts"
|
|
14
|
+
- "Creating forms and validations"
|
|
15
|
+
- "Implementing accessibility features"
|
|
16
|
+
- "Working on user-facing features"
|
|
17
|
+
- "Optimizing performance for frontend"
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Frontend Development Guidelines
|
|
21
|
+
|
|
22
|
+
Technology-agnostic patterns for building secure, accessible user interfaces.
|
|
23
|
+
|
|
24
|
+
## Core Principles
|
|
25
|
+
|
|
26
|
+
### User Experience
|
|
27
|
+
- **Responsive design** - Works on mobile, tablet, and desktop
|
|
28
|
+
- **Progressive enhancement** - Content works without JavaScript when possible
|
|
29
|
+
- **Fast performance** - Minimize blocking resources, lazy load non-critical content
|
|
30
|
+
- **Accessibility** - WCAG 2.1 AA compliance for all users
|
|
31
|
+
- **Error handling** - Clear, helpful error messages and graceful degradation
|
|
32
|
+
|
|
33
|
+
### Security
|
|
34
|
+
- **Input validation** - Validate all user input on client and server
|
|
35
|
+
- **Output encoding** - Escape data based on context (HTML, URL, CSS, JavaScript)
|
|
36
|
+
- **No sensitive data** - Never include passwords, tokens, or secrets in client code
|
|
37
|
+
- **Content Security Policy** - Restrict which resources can load
|
|
38
|
+
- **HTTPS only** - Enforce in production environments
|
|
39
|
+
|
|
40
|
+
### Accessibility
|
|
41
|
+
- **Semantic HTML** - Use appropriate elements for structure and meaning
|
|
42
|
+
- **ARIA attributes** - Include when semantic HTML is insufficient
|
|
43
|
+
- **Keyboard navigation** - Full functionality with keyboard only
|
|
44
|
+
- **Color contrast** - WCAG AA standard contrast ratios
|
|
45
|
+
- **Focus indicators** - Clear visual indicator of focused element
|
|
46
|
+
- **Alt text** - Descriptive alt text for all meaningful images
|
|
47
|
+
- **Form labels** - Associated labels for all form inputs
|
|
48
|
+
|
|
49
|
+
## Component Development
|
|
50
|
+
|
|
51
|
+
### Component Structure Pattern
|
|
52
|
+
|
|
53
|
+
Component responsibilities:
|
|
54
|
+
1. Clear purpose - One thing the component does
|
|
55
|
+
2. Props interface - Document all inputs clearly
|
|
56
|
+
3. Error handling - Handle invalid inputs gracefully
|
|
57
|
+
4. Accessibility - Include ARIA and semantic attributes
|
|
58
|
+
5. Testing - Can be tested in isolation
|
|
59
|
+
|
|
60
|
+
### Component Patterns (Language-Agnostic)
|
|
61
|
+
|
|
62
|
+
Component Naming:
|
|
63
|
+
- File names: kebab-case (user-profile, navigation-bar)
|
|
64
|
+
- Component names: PascalCase (UserProfile, NavigationBar)
|
|
65
|
+
|
|
66
|
+
Component Organization:
|
|
67
|
+
- Props at top
|
|
68
|
+
- State management
|
|
69
|
+
- Effects/lifecycle
|
|
70
|
+
- Event handlers
|
|
71
|
+
- Render/JSX at bottom
|
|
72
|
+
|
|
73
|
+
### Form Development
|
|
74
|
+
|
|
75
|
+
Form Validation Pattern:
|
|
76
|
+
1. Define validation schema (JavaScript, Zod, Yup, etc.)
|
|
77
|
+
2. Validate on change for feedback
|
|
78
|
+
3. Validate on blur for efficiency
|
|
79
|
+
4. Show field-specific errors
|
|
80
|
+
5. Disable submit until valid
|
|
81
|
+
6. Validate on server before processing
|
|
82
|
+
|
|
83
|
+
Form Accessibility:
|
|
84
|
+
- Label associated with each input
|
|
85
|
+
- Error messages linked to field
|
|
86
|
+
- Required fields marked clearly
|
|
87
|
+
- Tab order logical and visible
|
|
88
|
+
- Focus management in forms
|
|
89
|
+
- Error summary at top (optional)
|
|
90
|
+
|
|
91
|
+
### Responsive Design Patterns
|
|
92
|
+
|
|
93
|
+
Breakpoint-based design:
|
|
94
|
+
- Mobile first approach
|
|
95
|
+
- Add complexity at larger sizes
|
|
96
|
+
- Use media queries or responsive framework
|
|
97
|
+
- Test on actual devices
|
|
98
|
+
- Common breakpoints:
|
|
99
|
+
- Mobile: 0-480px
|
|
100
|
+
- Tablet: 481-768px
|
|
101
|
+
- Desktop: 769-1024px
|
|
102
|
+
- Wide: 1025px+
|
|
103
|
+
|
|
104
|
+
### State Management
|
|
105
|
+
|
|
106
|
+
Choose ONE approach for consistency:
|
|
107
|
+
- **Client-side**: Component state (useState, reactive variables)
|
|
108
|
+
- **Context/Provider**: Shared state across components
|
|
109
|
+
- **Centralized**: Redux, Vuex, Pinia, or similar
|
|
110
|
+
- **Server state**: Load from API, cache locally
|
|
111
|
+
- **Local storage**: Persistent browser storage
|
|
112
|
+
|
|
113
|
+
Keep state:
|
|
114
|
+
- As local as possible
|
|
115
|
+
- Close to where used
|
|
116
|
+
- Immutable when possible
|
|
117
|
+
- Easy to reason about
|
|
118
|
+
|
|
119
|
+
## Design System & Styling
|
|
120
|
+
|
|
121
|
+
### CSS Approach Options
|
|
122
|
+
|
|
123
|
+
Choose ONE approach:
|
|
124
|
+
- **Utility classes** (Tailwind CSS, UnoCSS)
|
|
125
|
+
- **Styled components** (styled-components, Emotion)
|
|
126
|
+
- **CSS Modules** (scoped styles)
|
|
127
|
+
- **BEM Convention** (Block-Element-Modifier)
|
|
128
|
+
- **Atomic CSS** (Atomic design principles)
|
|
129
|
+
|
|
130
|
+
Styling Principles:
|
|
131
|
+
- Consistent spacing using scale (4px, 8px, 12px, etc.)
|
|
132
|
+
- Limited color palette
|
|
133
|
+
- Consistent font sizing
|
|
134
|
+
- Consistent border radius
|
|
135
|
+
- Consistent shadows
|
|
136
|
+
- Dark/light mode support when needed
|
|
137
|
+
|
|
138
|
+
### Design Tokens
|
|
139
|
+
|
|
140
|
+
Define design system tokens:
|
|
141
|
+
- Colors: primary, secondary, danger, success, warning
|
|
142
|
+
- Typography: font families, sizes, weights, line heights
|
|
143
|
+
- Spacing: margin/padding scale (4px, 8px, 16px, 32px, etc.)
|
|
144
|
+
- Shadows: subtle, regular, strong
|
|
145
|
+
- Border radius: small, medium, large
|
|
146
|
+
- Animations: duration, easing
|
|
147
|
+
|
|
148
|
+
Use tokens consistently:
|
|
149
|
+
- In components
|
|
150
|
+
- In styles
|
|
151
|
+
- In tests
|
|
152
|
+
- In documentation
|
|
153
|
+
|
|
154
|
+
## Performance Optimization
|
|
155
|
+
|
|
156
|
+
### Image Optimization
|
|
157
|
+
- Use appropriate formats (WebP, JPEG, PNG)
|
|
158
|
+
- Provide multiple sizes (srcset)
|
|
159
|
+
- Lazy load below the fold
|
|
160
|
+
- Responsive images
|
|
161
|
+
- Optimize file size
|
|
162
|
+
|
|
163
|
+
### Code Splitting
|
|
164
|
+
- Split by route (page-based code splitting)
|
|
165
|
+
- Split by feature (feature-based code splitting)
|
|
166
|
+
- Split third-party libraries
|
|
167
|
+
- Load libraries on demand
|
|
168
|
+
|
|
169
|
+
### Caching Strategy
|
|
170
|
+
- Cache static assets (images, fonts, CSS, JS)
|
|
171
|
+
- Cache API responses appropriately
|
|
172
|
+
- Use service workers for offline support
|
|
173
|
+
- Clear cache on deployment
|
|
174
|
+
|
|
175
|
+
## Accessibility Checklist
|
|
176
|
+
|
|
177
|
+
Before releasing any UI:
|
|
178
|
+
|
|
179
|
+
- [ ] Semantic HTML is used correctly
|
|
180
|
+
- [ ] All images have descriptive alt text
|
|
181
|
+
- [ ] Color contrast meets WCAG AA standards
|
|
182
|
+
- [ ] Keyboard navigation works completely
|
|
183
|
+
- [ ] Focus indicators are visible
|
|
184
|
+
- [ ] Form inputs have associated labels
|
|
185
|
+
- [ ] Error messages are clear and specific
|
|
186
|
+
- [ ] Headings have correct hierarchy
|
|
187
|
+
- [ ] ARIA attributes used when appropriate
|
|
188
|
+
- [ ] Mobile layout is responsive
|
|
189
|
+
- [ ] Text is readable at smaller sizes
|
|
190
|
+
- [ ] Content structure makes sense without CSS
|
|
191
|
+
- [ ] No information conveyed by color alone
|
|
192
|
+
|
|
193
|
+
## Browser Compatibility
|
|
194
|
+
|
|
195
|
+
Support strategy:
|
|
196
|
+
- Define minimum versions to support
|
|
197
|
+
- Use feature detection or progressive enhancement
|
|
198
|
+
- Test critical paths in target browsers
|
|
199
|
+
- Provide fallbacks for older browsers
|
|
200
|
+
- Use polyfills when appropriate
|
|
201
|
+
|
|
202
|
+
## Testing Frontend Components
|
|
203
|
+
|
|
204
|
+
Unit tests:
|
|
205
|
+
- Component renders with props
|
|
206
|
+
- Event handlers work correctly
|
|
207
|
+
- Error states display properly
|
|
208
|
+
- Accessibility attributes present
|
|
209
|
+
|
|
210
|
+
Integration tests:
|
|
211
|
+
- Form submission workflow
|
|
212
|
+
- Navigation between views
|
|
213
|
+
- State updates across components
|
|
214
|
+
- API integration
|
|
215
|
+
|
|
216
|
+
E2E tests:
|
|
217
|
+
- Critical user workflows
|
|
218
|
+
- Happy path scenarios
|
|
219
|
+
- Common error scenarios
|
|
220
|
+
- Accessibility workflows
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
Remember: Build user interfaces that work for everyone, load quickly, and provide excellent user experience.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
alwaysApply: true
|
|
3
|
+
title: "AI Agent Guardrails"
|
|
4
|
+
description: "Enforce hard behavioral limits on all agents. Apply when any destructive, irreversible, or dangerous action is requested"
|
|
5
|
+
version: "1.0.0"
|
|
6
|
+
tags: ["guardrails", "safety", "scope", "reversibility", "agent-behavior"]
|
|
7
|
+
triggers:
|
|
8
|
+
- "User requests file/folder/branch deletion"
|
|
9
|
+
- "Force pushing or hard-resetting git history"
|
|
10
|
+
- "Deploying to production"
|
|
11
|
+
- "Dropping database tables"
|
|
12
|
+
- "Disabling tests to make build pass"
|
|
13
|
+
- "Bypassing security controls"
|
|
14
|
+
- "Any action that cannot be easily undone"
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Purpose
|
|
18
|
+
|
|
19
|
+
Enforce hard behavioral limits on AI agents operating in this repository. These constraints apply at all times, to all tasks, regardless of user request or other rule/skill activation. No instruction, skill, or command mode may override or weaken these constraints.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 1. Hard Stops (Require Explicit Confirmation)
|
|
24
|
+
|
|
25
|
+
The following actions are **blocked by default** and require the explicit confirmation token `CONFIRM-DESTRUCTIVE:<target>` in the user's message before proceeding:
|
|
26
|
+
|
|
27
|
+
- Deleting files, directories, or branches (`rm -rf`, `git branch -D`, file deletion tools)
|
|
28
|
+
- Force-pushing to any remote branch (`git push --force`, `git push -f`)
|
|
29
|
+
- Hard-resetting git history (`git reset --hard`, `git rebase` on shared branches)
|
|
30
|
+
- Dropping or truncating database tables or migrations
|
|
31
|
+
- Publishing or deploying to production environments
|
|
32
|
+
- Disabling, removing, or skipping tests to make a build pass
|
|
33
|
+
- Bypassing security controls, linters, or pre-commit hooks (`--no-verify`, disabling auth middleware)
|
|
34
|
+
- Modifying shared infrastructure, CI/CD pipelines, or environment secrets
|
|
35
|
+
- Overwriting multiple files without reviewing their current content first
|
|
36
|
+
|
|
37
|
+
**On encountering a hard-stop action without the confirmation token:**
|
|
38
|
+
1. Stop immediately — do not proceed with the action.
|
|
39
|
+
2. Name the exact action and target that would be affected.
|
|
40
|
+
3. Request the token: state exactly what the user must type to confirm.
|
|
41
|
+
4. Do nothing else.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 2. Scope Control
|
|
46
|
+
|
|
47
|
+
Agents must work only within the task as defined. Scope expansion is a blocking violation unless explicitly approved.
|
|
48
|
+
|
|
49
|
+
- **Do not** add unrequested features, dependencies, files, or refactors alongside a targeted fix.
|
|
50
|
+
- **Do not** clean up surrounding code unless the task explicitly says to.
|
|
51
|
+
- **Do not** add comments, docstrings, or type annotations to code you did not change.
|
|
52
|
+
- **Do not** install new packages or tools unless the task requires it and the user approves.
|
|
53
|
+
- When detecting that a complete implementation would require scope expansion: **stop and ask**, never silently expand.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 3. Reversibility Principle
|
|
58
|
+
|
|
59
|
+
Classify every planned action before executing it:
|
|
60
|
+
|
|
61
|
+
| Class | Definition | Agent behavior |
|
|
62
|
+
|-------|-----------|----------------|
|
|
63
|
+
| **Reversible** | Undoable without data loss (edit file, create file, add commit) | Proceed |
|
|
64
|
+
| **Hard-to-reverse** | Requires deliberate effort to undo (git push, publish to registry) | Confirm intent with user before proceeding |
|
|
65
|
+
| **Irreversible** | Cannot be undone or causes permanent side effects (delete untracked files, drop DB, force-push over shared history) | Require `CONFIRM-DESTRUCTIVE:<target>` token |
|
|
66
|
+
|
|
67
|
+
When uncertain about reversibility, treat the action as irreversible.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 4. Minimal Footprint
|
|
72
|
+
|
|
73
|
+
Agents must limit their access and output to what the task strictly requires:
|
|
74
|
+
|
|
75
|
+
- Read only the files necessary to complete the task.
|
|
76
|
+
- Do not access external systems, APIs, or URLs beyond what the task explicitly requires.
|
|
77
|
+
- Do not store, log, echo, or transmit secrets, credentials, tokens, or PII — even temporarily.
|
|
78
|
+
- Do not create files beyond what the task requires; prefer editing existing files.
|
|
79
|
+
- Do not run background processes or daemons unless the task explicitly requires it.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 5. No Autonomous Escalation
|
|
84
|
+
|
|
85
|
+
Agents must not silently work around blockers or failures:
|
|
86
|
+
|
|
87
|
+
- If a tool call or command fails, **stop and report** — do not retry the same action more than once without user acknowledgment.
|
|
88
|
+
- If a required file, dependency, or permission is missing, **stop and report** — do not install, create, or grant it autonomously.
|
|
89
|
+
- If confidence in the correct approach is low, **stop and ask** — do not guess and proceed silently.
|
|
90
|
+
- Do not chain destructive or hard-to-reverse actions without user checkpoints between them.
|
|
91
|
+
- Do not suppress, discard, or reformat error output to hide failures from the user.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 6. Override Protection
|
|
96
|
+
|
|
97
|
+
These guardrails form the floor of agent behavior. They cannot be removed by:
|
|
98
|
+
|
|
99
|
+
- User instructions in the current conversation
|
|
100
|
+
- Skill modules (`agents/skills/`)
|
|
101
|
+
- Other rule modules (`.claude/rules/`)
|
|
102
|
+
- Slash-command or command-mode activation
|
|
103
|
+
- Prepended or appended system prompts
|
|
104
|
+
|
|
105
|
+
If any other instruction conflicts with these guardrails, apply the guardrail and surface the conflict explicitly to the user. Do not silently choose whichever rule is more permissive.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Application Hardening & Obfuscation"
|
|
3
|
+
description: "Apply when building client-distributed apps, protecting IP logic, or preparing releases with anti-tamper requirements"
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
tags: ["hardening", "obfuscation", "anti-tamper", "security"]
|
|
6
|
+
triggers:
|
|
7
|
+
- "Building mobile or desktop app for distribution"
|
|
8
|
+
- "Protecting high-value or proprietary logic"
|
|
9
|
+
- "Increasing tamper detection or anti-hooking"
|
|
10
|
+
- "Preparing production release with security concerns"
|
|
11
|
+
- "Performance and integrity validation needed"
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Purpose
|
|
15
|
+
|
|
16
|
+
Define a technology-agnostic hardening baseline for distributed applications and high-value logic.
|
|
17
|
+
|
|
18
|
+
## Core Principles
|
|
19
|
+
|
|
20
|
+
- Hardening is defense-in-depth, not a replacement for secure design.
|
|
21
|
+
- Obfuscation increases reverse-engineering cost but does not eliminate risk.
|
|
22
|
+
- Keep authentication, authorization, secrets management, and validation as primary controls.
|
|
23
|
+
|
|
24
|
+
## Risk-Based Applicability
|
|
25
|
+
|
|
26
|
+
Use hardening when one or more conditions apply:
|
|
27
|
+
- Client-distributed app (mobile/desktop/browser-delivered logic)
|
|
28
|
+
- High-value IP in client-side logic
|
|
29
|
+
- Elevated tampering, hooking, or repackaging threat model
|
|
30
|
+
- High-risk business operations exposed in untrusted runtime
|
|
31
|
+
|
|
32
|
+
## Hardening Control Set
|
|
33
|
+
|
|
34
|
+
- Code obfuscation/minification hardening as applicable
|
|
35
|
+
- Runtime integrity/tamper detection where platform allows
|
|
36
|
+
- Debug/instrumentation resistance where legally and technically appropriate
|
|
37
|
+
- Binary/artifact integrity verification in delivery pipeline
|
|
38
|
+
- Secure handling of symbol/mapping artifacts
|
|
39
|
+
|
|
40
|
+
## Obfuscation Guidance
|
|
41
|
+
|
|
42
|
+
- Apply near build/release stage, not as source-authoring substitute.
|
|
43
|
+
- Validate behavior after obfuscation with full regression checks.
|
|
44
|
+
- Enforce performance and startup budget checks post-hardening.
|
|
45
|
+
- Maintain reproducible builds and deterministic config snapshots.
|
|
46
|
+
|
|
47
|
+
## Verification Requirements
|
|
48
|
+
|
|
49
|
+
- Functional regression tests pass on hardened build.
|
|
50
|
+
- Performance budgets remain within accepted thresholds.
|
|
51
|
+
- Crash/debug workflow documented with restricted symbol access.
|
|
52
|
+
- Release notes include hardening profile and known tradeoffs.
|
|
53
|
+
|
|
54
|
+
## Safety Constraints
|
|
55
|
+
|
|
56
|
+
- Do not claim obfuscation as complete protection.
|
|
57
|
+
- Do not rely on obfuscation to protect embedded secrets.
|
|
58
|
+
- Block release if hardening-required profile lacks verification evidence.
|