Skip to content

Commit 7ad1789

Browse files
committed
feat: add Antigravity minimal profile rules
1 parent 31827cf commit 7ad1789

3 files changed

Lines changed: 303 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
trigger: always_on
3+
---
4+
5+
# Accessibility Basics
6+
7+
## Core Requirements
8+
9+
- All interactive elements must be keyboard accessible (Tab, Enter, Space)
10+
- Provide alt text for images that convey information
11+
- Use semantic HTML elements (button, nav, main, header, footer)
12+
- Minimum color contrast: 4.5:1 for normal text
13+
14+
## Keyboard Navigation
15+
16+
- Support Tab key for navigation
17+
- Support Enter/Space for activation
18+
- Visible focus indicators required
19+
- Never use `tabIndex > 0`
20+
21+
## Screen Readers
22+
23+
- Use semantic HTML first (button instead of div with onClick)
24+
- Provide alt text for meaningful images
25+
- Use alt="" for decorative images
26+
- Form fields must have associated labels
27+
28+
## Color and Contrast
29+
30+
- Text must have 4.5:1 contrast ratio minimum
31+
- Don't use color alone to convey information
32+
- Add icons or text labels in addition to color
33+
34+
## Forms
35+
36+
- All inputs must have labels
37+
- Indicate required fields clearly
38+
- Provide helpful error messages
39+
- Support keyboard navigation
40+
41+
## Testing
42+
43+
- Test with keyboard only (no mouse)
44+
- Use browser accessibility tools (Axe, Lighthouse)
45+
- Check color contrast with analyzer tool
46+
47+
## Quick Checklist
48+
49+
- [ ] Can I navigate with keyboard only?
50+
- [ ] Do all images have alt text?
51+
- [ ] Are buttons actually button elements?
52+
- [ ] Do form fields have labels?
53+
- [ ] Is color contrast sufficient?
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
trigger: always_on
3+
---
4+
5+
# Code Quality Essentials
6+
7+
## Naming Conventions
8+
9+
- Variables & functions: `camelCase` (getUserData, isValid)
10+
- Components: `PascalCase` (UserProfile, Button)
11+
- Constants: `UPPER_SNAKE_CASE` (MAX_RETRIES, API_URL)
12+
- Be descriptive: `isUserAuthenticated` not `isAuth`
13+
14+
## JavaScript Basics
15+
16+
- Use `const` by default, `let` only when reassigning
17+
- Never use `var`
18+
- Use arrow functions for callbacks
19+
- Remove `console.log` before committing
20+
- Use template literals: \`Hello ${name}\` not "Hello " + name
21+
22+
## Functions
23+
24+
- Keep functions small (under 50 lines)
25+
- Functions should do one thing
26+
- Use descriptive names that explain what they do
27+
- Avoid deeply nested code (max 3 levels)
28+
29+
## Code Organization
30+
31+
- One component per file
32+
- Group related files in folders
33+
- Import order: React, libraries, local files
34+
- Remove unused imports and code
35+
36+
## Common Patterns
37+
38+
### Good Practices
39+
40+
```javascript
41+
// Destructure props
42+
const Button = ({ onClick, label }) => (
43+
<button onClick={onClick}>{label}</button>
44+
);
45+
46+
// Use early returns
47+
const getStatus = (user) => {
48+
if (!user) return "guest";
49+
if (user.isPremium) return "premium";
50+
return "standard";
51+
};
52+
53+
// Named functions for handlers
54+
const handleClick = () => {
55+
console.log("clicked");
56+
};
57+
```
58+
59+
### Avoid
60+
61+
```javascript
62+
// Don't access props directly
63+
const Button = (props) => (
64+
<button onClick={props.onClick}>{props.label}</button>
65+
);
66+
67+
// Don't use anonymous functions in JSX
68+
<button onClick={() => handleClick()}>Click</button>;
69+
70+
// Don't nest too deeply
71+
if (condition1) {
72+
if (condition2) {
73+
if (condition3) {
74+
// too deep!
75+
}
76+
}
77+
}
78+
```
79+
80+
## Quick Checklist
81+
82+
- [] Descriptive variable name?
83+
- [] Functions under 50 lines?
84+
- [] No console.log statements?
85+
- [] Imports organized?
86+
- [] Dead code removed?
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
trigger: always_on
3+
---
4+
5+
# React Component Basics
6+
7+
## Component Structure
8+
9+
- Use functional components with hooks (not class components)
10+
- Destructure props at function signature
11+
- Keep components under 200 lines
12+
- One component per file
13+
14+
## Props
15+
16+
````javascript
17+
// Good: Destructure props
18+
const UserCard = ({name, email, onEdit}) => (
19+
<div>
20+
<h2>{name}</h2>
21+
<p>{email}</p>
22+
<button onClick={onEdit}>Edit</button>
23+
</div>
24+
);
25+
26+
// Bad: Using props object
27+
const UserCard = (props) => (
28+
<div>
29+
<h2>{props.name}</h2>
30+
<p>{props.email}</p>
31+
<button onClick={props.onEdit}>Edit</button>
32+
</div>
33+
);
34+
35+
## Hooks Basic
36+
37+
### useState
38+
Use for local UI state only (modals, toggles, input values)
39+
```javascript
40+
const [isOpen, setIsOpen] = useState(false);
41+
const [count, setCount] = useState(0);
42+
````
43+
44+
### useEffect
45+
46+
Use for side effects (API calls, subscriptions, timers)
47+
48+
```javascript
49+
useEffect(() => {
50+
// Do something
51+
fetchData();
52+
53+
// Cleanup (optional)
54+
return () => cleanup();
55+
}, [dependencies]); // Don't forget dependencies!
56+
```
57+
58+
### useCallback
59+
60+
Prevent function recreation on every render
61+
62+
```javascript
63+
const handleClick = useCallback(() => {
64+
doSomething();
65+
}, [dependencies]);
66+
```
67+
68+
## JSX Best Practices
69+
70+
- Use semantic HTML (button, nav, header, footer)
71+
- No anonymous functions in JSX: onClick={handleClick} not onClick={() => handleClick()}
72+
- Keys must be from data, not array index: key={item.id} not key={index}
73+
- Use fragments <></> instead of unnecessary divs
74+
- Conditional rendering: use boolean values only
75+
76+
## Common Patterns
77+
78+
### Event Handlers
79+
80+
```javascript
81+
// Good: Named function
82+
const handleSubmit = (e) => {
83+
e.preventDefault();
84+
submitForm();
85+
};
86+
87+
<form onSubmit={handleSubmit}>
88+
89+
// Bad: Anonymous function
90+
<form onSubmit={(e) => {
91+
e.preventDefault();
92+
submitForm();
93+
}}>
94+
```
95+
96+
### Conditional Rendering
97+
98+
```javascript
99+
// Good: Boolean condition
100+
{
101+
isLoggedIn && <Dashboard />;
102+
}
103+
104+
// Good: Ternary for two states
105+
{
106+
isLoading ? <Spinner /> : <Content />;
107+
}
108+
109+
// Bad: Can accidentally render "0"
110+
{
111+
count && <Display />;
112+
}
113+
```
114+
115+
### Lists
116+
117+
```javascript
118+
// Good: Key from data
119+
{
120+
users.map((user) => <UserCard key={user.id} {...user} />);
121+
}
122+
123+
// Bad: Index as key
124+
{
125+
users.map((user, index) => <UserCard key={index} {...user} />);
126+
}
127+
```
128+
129+
### Component Organization
130+
131+
```javascript
132+
const MyComponent = ({ prop1, prop2 }) => {
133+
// 1. Hooks
134+
const [state, setState] = useState();
135+
136+
// 2. Event handlers
137+
const handleClick = () => {
138+
// handle click
139+
};
140+
141+
// 3. Early returns
142+
if (!prop1) return null;
143+
144+
// 4. Render
145+
return <div>{/* JSX here */}</div>;
146+
};
147+
```
148+
149+
## Avoid
150+
151+
- Class components (use functional components)
152+
- Direct DOM manipulation (use refs sparingly)
153+
- Inline styles (use CSS/styled-components)
154+
- Prop drilling beyond 3 levels (use context or Redux)
155+
- Components over 200 lines (break them down)
156+
157+
## Quick Checklist
158+
159+
- [] Using functional components?
160+
- [] Props destructured?
161+
- [] Event handlers named?
162+
- [] Keys from data, not index?
163+
- [] Component under 200 lines?
164+
- [] useEffect has dependencies?

0 commit comments

Comments
 (0)