codingwithagent 1.0.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.
Files changed (33) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/bin/init.js +257 -0
  4. package/package.json +56 -0
  5. package/templates/accessibility/.cursorrules +342 -0
  6. package/templates/accessibility/README.md +47 -0
  7. package/templates/antigravity/accessibility/.agent/rules/accessibility.md +501 -0
  8. package/templates/antigravity/accessibility/.agent/rules/aria-patterns.md +568 -0
  9. package/templates/antigravity/accessibility/.agent/rules/wcag-standard.md +225 -0
  10. package/templates/antigravity/accessibility/README.md +42 -0
  11. package/templates/antigravity/minimal/.agent/rules/accessibility.md +53 -0
  12. package/templates/antigravity/minimal/.agent/rules/code-quality.md +86 -0
  13. package/templates/antigravity/minimal/.agent/rules/react-components.md +164 -0
  14. package/templates/antigravity/minimal/README.md +34 -0
  15. package/templates/antigravity/standard/.agent/rules/accessibility.md +98 -0
  16. package/templates/antigravity/standard/.agent/rules/code-quality.md +166 -0
  17. package/templates/antigravity/standard/.agent/rules/pull-request-review.md +192 -0
  18. package/templates/antigravity/standard/.agent/rules/react-components.md +204 -0
  19. package/templates/antigravity/standard/.agent/rules/testing.md +197 -0
  20. package/templates/antigravity/standard/README.md +39 -0
  21. package/templates/antigravity/strict/.agent/README.md +46 -0
  22. package/templates/antigravity/strict/.agent/rules/accessibility.md +199 -0
  23. package/templates/antigravity/strict/.agent/rules/code-quality.md +268 -0
  24. package/templates/antigravity/strict/.agent/rules/pull-request-review.md +114 -0
  25. package/templates/antigravity/strict/.agent/rules/react-components.md +423 -0
  26. package/templates/antigravity/strict/.agent/rules/security.md +483 -0
  27. package/templates/antigravity/strict/.agent/rules/testing.md +280 -0
  28. package/templates/minimal/.cursorrules +48 -0
  29. package/templates/minimal/README.md +40 -0
  30. package/templates/standard/.cursorrules +184 -0
  31. package/templates/standard/README.md +43 -0
  32. package/templates/strict/.cursorrules +227 -0
  33. package/templates/strict/README.md +47 -0
@@ -0,0 +1,197 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # Testing Standards and Requirements
6
+
7
+ ## Testing Philosophy
8
+
9
+ - Tests ensure code quality and prevent regressions
10
+ - Unit tests must accompany all new code
11
+ - Tests are living documentation
12
+ - Coverage should increase or maintain, never decrease
13
+ - Write tests that would catch real bugs
14
+
15
+ ## Coverage Requirements
16
+
17
+ - Maintain unit test threshold for modern codebases
18
+ - Aim for 80%+ coverage on new code
19
+ - Report previous and current coverage in PRs
20
+ - 100% coverage = previous not needed in PR
21
+ - Coverage decrease requires justification
22
+
23
+ ## Unit Testing Standards
24
+
25
+ ### What to Test
26
+
27
+ - All exported functions and utilities
28
+ - Component rendering with various props
29
+ - Conditional logic and edge cases
30
+ - Event handlers and user interactions
31
+ - State changes and Redux actions
32
+ - Error handling and boundary conditions
33
+ - PropTypes validation
34
+
35
+ ### What NOT to Test
36
+
37
+ - Third-party library internals
38
+ - Trivial getters/setters
39
+ - Constant values
40
+ - External API implementations (mock these)
41
+
42
+ ### Unit Test Best Practices
43
+
44
+ - **Shallow render preferred**: Use shallow unless hooks require mount
45
+ - **Single instance per scope**: Reuse component instance, update props/state
46
+ - **No long timeouts**: Keep setTimeout < 100ms if needed
47
+ - **Avoid snapshots**: Remove when possible, update reluctantly
48
+ - **Mock external dependencies**: APIs, Redux store, third-party libraries
49
+ - **Clean up mocks**: Use beforeEach and afterAll to reset
50
+
51
+ ### Test Structure
52
+
53
+ ```javascript
54
+ describe("ComponentName", () => {
55
+ let wrapper;
56
+ let props;
57
+
58
+ beforeEach(() => {
59
+ props = {
60
+ // default props
61
+ };
62
+ });
63
+
64
+ afterAll(() => {
65
+ jest.clearAllMocks();
66
+ });
67
+
68
+ it("should render correctly with default props", () => {
69
+ wrapper = shallow(<ComponentName {...props} />);
70
+ expect(wrapper.exists()).toBe(true);
71
+ });
72
+
73
+ it("should call onClick handler when button clicked", () => {
74
+ const mockOnClick = jest.fn();
75
+ wrapper = shallow(<ComponentName {...props} onClick={mockOnClick} />);
76
+ wrapper.find("button").simulate("click");
77
+ expect(mockOnClick).toHaveBeenCalledTimes(1);
78
+ });
79
+ });
80
+ ```
81
+
82
+ ### Dates in Tests
83
+
84
+ - Do NOT mock dates in the future
85
+ - Override moment.now in tests if current date used
86
+ - Use consistent date formats
87
+ - Test timezone handling
88
+
89
+ ### Component Testing
90
+
91
+ - Test all user interactions
92
+ - Verify proper prop handling
93
+ - Test conditional rendering paths
94
+ - Verify event handlers fire correctly
95
+ - Test error states and loading states
96
+ - Accessibility: Test keyboard navigation, ARIA labels
97
+
98
+ ### Integration Testing
99
+
100
+ - Test user journeys across multiple components
101
+ - Verify data flow through Redux
102
+ - Test routing and navigation
103
+ - Verify API integration with mocked responses
104
+
105
+ ### Testing Tools
106
+
107
+ - Jest: Test runner and assertion library
108
+ - React Testing Library: Component testing (preferred)
109
+ - Enzyme: Shallow/mount rendering (legacy, minimize use)
110
+ - React Hooks Testing Library: For custom hooks
111
+ - Mock Service Worker (MSW): API mocking
112
+
113
+ ### Test Naming Conventions
114
+
115
+ - Describe blocks: Component or function name
116
+ - It blocks: "should [expected behavior] when [condition]"
117
+ - Be specific and descriptive
118
+ - Avoid "works correctly" or "is defined"
119
+
120
+ ```javascript
121
+ // GOOD
122
+ it("should display error message when form submission fails", () => {});
123
+ it("should disable submit button when form is invalid", () => {});
124
+
125
+ // BAD
126
+ it("works correctly", () => {});
127
+ it("handles errors", () => {});
128
+ ```
129
+
130
+ ## Mocking Best Practices
131
+
132
+ ### When to Mock
133
+
134
+ - External API calls
135
+ - Redux store and actions
136
+ - Browser APIs (localStorage, window, document)
137
+ - Third-party libraries
138
+ - Time-dependent functions (Date, moment)
139
+ - File system operations
140
+
141
+ ### How to Mock
142
+
143
+ ```javascript
144
+ // Mock module
145
+ jest.mock("../utils/api", () => ({
146
+ fetchData: jest.fn(),
147
+ }));
148
+
149
+ // Mock with implementation
150
+ const mockFn = jest.fn((a, b) => a + b);
151
+
152
+ // Restore after tests
153
+ afterEach(() => {
154
+ jest.clearAllMocks();
155
+ });
156
+
157
+ afterAll(() => {
158
+ jest.restoreAllMocks();
159
+ });
160
+ ```
161
+
162
+ ### What NOT to Mock
163
+
164
+ - Component's own functions (test real behavior)
165
+ - Simple utility functions (test actual implementation)
166
+ - PropTypes validation
167
+ - React internals
168
+
169
+ ## Testing Anti-Patterns
170
+
171
+ ### Avoid These
172
+
173
+ - Testing implementation details instead of behavior
174
+ - Testing third-party library internals
175
+ - Snapshot tests without review
176
+ - Excessive mocking that doesn't reflect real usage
177
+ - Tests that pass regardless of code correctness
178
+ - setTimeout without cleanup
179
+ - Tests depending on execution order
180
+
181
+ ### Do This Instead
182
+
183
+ - Test user-visible behavior
184
+ - Mock external dependencies only
185
+ - Explicit assertions over snapshots
186
+ - Realistic mocks reflecting actual API responses
187
+ - Assertions that would fail if code breaks
188
+ - Immediate assertions or controlled timing
189
+ - Independent, isolated tests
190
+
191
+ ### Accessibility Testing
192
+
193
+ - Test keyboard navigation (Tab, Enter, Space, Escape)
194
+ - Verify ARIA labels and roles
195
+ - Test screen reader announcements
196
+ - Verify focus management
197
+ - Test with accessibility testing libraries
@@ -0,0 +1,39 @@
1
+ # Antigravity - Standard Profile ⭐
2
+
3
+ Recommended baseline for production code with comprehensive rules.
4
+
5
+ ## What's Included
6
+
7
+ 5 detailed rule files:
8
+
9
+ - `accessibility.md` - WCAG 2.1 AA standards
10
+ - `code-quality.md` - Naming, patterns, best practices
11
+ - `react-components.md` - Hooks, JSX, component design
12
+ - `testing.md` - 80%+ coverage, testing patterns
13
+ - `pull-request-review.md` - PR standards and review checklist
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npx codingwithagent init
19
+ # Select tool: 3. Antigravity
20
+ # Select profile: 2. Standard
21
+ ```
22
+
23
+ ## Files created
24
+
25
+ ```
26
+ .agent/rules/
27
+ ├── accessibility.md
28
+ ├── code-quality.md
29
+ ├── react-components.md
30
+ ├── testing.md
31
+ └── pull-request-review.md
32
+ ```
33
+
34
+ ## Best For
35
+
36
+ - Production applications
37
+ - Team projects
38
+ - Enterprise development
39
+ - Long-term maintenance
@@ -0,0 +1,46 @@
1
+ # Antigravity - Strict Profile
2
+
3
+ Maximum enforcement with zero tolerance for violations.
4
+
5
+ ## What's Included
6
+
7
+ 6 comprehensive rule files:
8
+
9
+ - `accessibility.md` - WCAG 2.1 AAA standards
10
+ - `code-quality.md` - 90% coverage, TypeScript mandatory
11
+ - `react-components.md` - 100% component coverage, strict hooks
12
+ - `testing.md` - 90% minimum, zero flaky tests
13
+ - `pull-request-review.md` - 2+ approvals, strict SLA
14
+ - `security.md` - OWASP compliance, zero vulnerabilities
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npx codingwithagent init
20
+ # Select tool: 3. Antigravity
21
+ # Select profile: 3. Strict
22
+ ```
23
+
24
+ ## Files created
25
+
26
+ ```
27
+ .agent/rules/
28
+ ├── accessibility.md
29
+ ├── code-quality.md
30
+ ├── react-components.md
31
+ ├── testing.md
32
+ ├── pull-request-review.md
33
+ └── security.md
34
+ ```
35
+
36
+ ## Requirements
37
+
38
+ - TypeScript (no `any` type)
39
+ - Components max 150 lines
40
+ - Lighthouse accessibility: 100
41
+ - Security vulnerabilities: 0
42
+ - Performance score: >90
43
+
44
+ ## Warning
45
+
46
+ Only use if committed to maximum quality.
@@ -0,0 +1,199 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # Accessibility Standards - STRICT (Zero Tolerance)
6
+
7
+ ## Compliance Requirements - MANDATORY
8
+
9
+ - WCAG 2.1 Level AA MINIMUM (AAA when possible)
10
+ - 100% keyboard accessibility (no exceptions)
11
+ - ALL features tested with screen readers before PR approval
12
+ - Automated accessibility tests REQUIRED in CI/CD
13
+ - Manual accessibility testing MANDATORY for all UI changes
14
+
15
+ ## POUR Principles - Strict Enforcement
16
+
17
+ ### Perceivable - MUST BE ACCESSIBLE
18
+
19
+ - ALL images MUST have alt text (or alt="" if decorative) - NO EXCEPTIONS
20
+ - ALL videos MUST have captions
21
+ - ALL audio MUST have transcripts
22
+ - Color contrast MUST be 4.5:1 minimum (7:1 for AAA preferred)
23
+ - NEVER use color alone to convey information
24
+ - Text MUST be resizable up to 200% without loss of content
25
+
26
+ ### Operable - MUST WORK WITH KEYBOARD
27
+
28
+ - ALL functionality MUST work with keyboard only
29
+ - Visible focus indicators REQUIRED (minimum 2px outline)
30
+ - Focus order MUST be logical
31
+ - NO keyboard traps (zero tolerance)
32
+ - NEVER use `tabIndex > 0` (PR rejection if found)
33
+ - NO time limits unless user can control them
34
+
35
+ ### Understandable - MUST BE CLEAR
36
+
37
+ - Proper heading hierarchy (h1 > h2 > h3, NO skipping)
38
+ - Semantic HTML MANDATORY (header, nav, main, footer, button)
39
+ - Form labels REQUIRED for ALL inputs
40
+ - Error messages MUST be clear and actionable
41
+ - Language attribute MUST be set on all pages
42
+
43
+ ### Robust - MUST WORK EVERYWHERE
44
+
45
+ - Valid HTML (pass W3C validator)
46
+ - Test with NVDA, JAWS, VoiceOver, TalkBack (ALL required)
47
+ - Works with assistive technologies
48
+ - Compatible with all major browsers + screen readers
49
+
50
+ ## Implementation Requirements - STRICT
51
+
52
+ ### Screen Reader Support - MANDATORY
53
+
54
+ - Use semantic HTML FIRST (button, not div with onClick)
55
+ - ARIA ONLY when semantic HTML insufficient
56
+ - role="alert" MUST be used sparingly (overuse = PR rejection)
57
+ - Announce ALL state changes (loading, success, error)
58
+ - Test EVERY feature with screen reader before PR
59
+
60
+ ### Form Accessibility - ZERO TOLERANCE
61
+
62
+ - ALL form fields MUST have associated labels (no visual-only labels)
63
+ - Required fields MUST be indicated programmatically
64
+ - Error messages MUST be associated with inputs (aria-describedby)
65
+ - Form validation MUST happen on blur or submit (not on every keystroke)
66
+ - Success confirmations MUST be announced to screen readers
67
+
68
+ ### Interactive Elements - STRICT REQUIREMENTS
69
+
70
+ - Buttons MINIMUM size: 44x44 CSS pixels (WCAG AAA)
71
+ - Links MUST have descriptive text (no "click here", "read more")
72
+ - External links MUST indicate new window/tab
73
+ - Custom controls MUST have proper ARIA attributes
74
+ - ALL custom actions MUST be keyboard accessible
75
+
76
+ ### Mobile Accessibility - MANDATORY
77
+
78
+ - Touch targets MINIMUM 44x44 pixels
79
+ - Pinch-to-zoom MUST be enabled (no viewport user-scalable=no)
80
+ - Test with VoiceOver (iOS) AND TalkBack (Android)
81
+ - Orientation changes MUST be supported
82
+ - Touch gestures MUST have keyboard alternatives
83
+
84
+ ## Testing Requirements - MANDATORY
85
+
86
+ ### Automated Testing - REQUIRED
87
+
88
+ - axe-core or jest-axe in ALL unit tests
89
+ - Lighthouse accessibility score MUST be 100
90
+ - pa11y in CI/CD pipeline (build fails on errors)
91
+ - ESLint jsx-a11y plugin with ALL rules enabled
92
+ - NO eslint-disable for a11y rules without architect approval
93
+
94
+ ### Manual Testing - REQUIRED BEFORE PR
95
+
96
+ - Keyboard navigation test (Tab, Shift+Tab, Enter, Space, Escape)
97
+ - Screen reader test with NVDA (Windows) OR VoiceOver (Mac)
98
+ - Color contrast analyzer (ALL text and UI elements)
99
+ - Zoom to 200% test (content must remain readable)
100
+ - Test with CSS disabled (content must be understandable)
101
+
102
+ ### Testing Checklist - ALL REQUIRED
103
+
104
+ - [ ] Keyboard navigation works for ALL functionality
105
+ - [ ] Visible focus indicators present
106
+ - [ ] Focus order is logical
107
+ - [ ] Screen reader announces content correctly
108
+ - [ ] Color contrast passes 4.5:1 (7:1 preferred)
109
+ - [ ] Alt text provided for ALL meaningful images
110
+ - [ ] Form labels properly associated
111
+ - [ ] Error messages clear and associated
112
+ - [ ] NO automatic timeouts
113
+ - [ ] NO flashing content
114
+ - [ ] Semantic HTML used throughout
115
+ - [ ] Zoom to 200% tested and working
116
+ - [ ] Mobile touch targets 44x44px minimum
117
+
118
+ ## Prohibited Practices - IMMEDIATE PR REJECTION
119
+
120
+ ### NEVER DO THESE
121
+
122
+ - NEVER use `tabIndex > 0`
123
+ - NEVER use color alone to convey information
124
+ - NEVER disable zoom (viewport user-scalable=no)
125
+ - NEVER use flashing/blinking content
126
+ - NEVER create keyboard traps
127
+ - NEVER use non-semantic HTML for interactive elements
128
+ - NEVER skip heading levels (h1 to h3)
129
+ - NEVER use `role="presentation"` on interactive elements
130
+ - NEVER use placeholder as label
131
+ - NEVER auto-play audio/video
132
+ - NEVER mock screen reader implementations with aria-label hacks
133
+
134
+ ## ARIA - Use ONLY When Necessary
135
+
136
+ ### First Rule of ARIA: Don't Use ARIA
137
+
138
+ - Use semantic HTML FIRST
139
+ - ARIA only when semantic HTML insufficient
140
+ - NEVER change semantic meaning with ARIA
141
+ - ALL ARIA controls MUST be keyboard accessible
142
+
143
+ ### Allowed ARIA Patterns (Only These)
144
+
145
+ - `aria-label`: When visual label not present
146
+ - `aria-labelledby`: Associate existing label
147
+ - `aria-describedby`: Additional description
148
+ - `aria-live`: Dynamic content announcements (polite or assertive only)
149
+ - `aria-expanded`: Collapsible content state
150
+ - `aria-hidden="true"`: Hide decorative elements ONLY
151
+ - `aria-invalid`: Form validation errors
152
+
153
+ ### ARIA Violations = PR Rejection
154
+
155
+ - Incorrect role usage
156
+ - Missing required ARIA attributes
157
+ - ARIA on non-interactive elements
158
+ - Conflicting ARIA and HTML semantics
159
+
160
+ ## Color Contrast - STRICT REQUIREMENTS
161
+
162
+ ### Minimum Ratios (AAA Preferred)
163
+
164
+ - Normal text: 4.5:1 minimum (7:1 for AAA)
165
+ - Large text (18pt+ or 14pt+ bold): 3:1 minimum (4.5:1 for AAA)
166
+ - UI components: 3:1 minimum
167
+ - Icons: 3:1 minimum
168
+ - States (hover, focus, active): 3:1 minimum
169
+
170
+ ### Testing Required
171
+
172
+ - Use Color Contrast Analyzer tool
173
+ - Test ALL color combinations
174
+ - Test hover/focus/active states
175
+ - Test with grayscale view
176
+ - Test with color blindness simulators
177
+
178
+ ## Enforcement
179
+
180
+ ### PR Review Requirements
181
+
182
+ - Accessibility checklist MUST be completed
183
+ - Screen reader testing video/screenshots required for UI changes
184
+ - Automated tests MUST pass (100 Lighthouse score)
185
+ - Manual testing MUST be documented
186
+ - Architect review REQUIRED for custom ARIA usage
187
+
188
+ ### Build Pipeline
189
+
190
+ - Builds FAIL on accessibility violations
191
+ - axe-core violations block merge
192
+ - Lighthouse score < 100 blocks merge
193
+ - ESLint a11y errors block merge
194
+
195
+ ## Resources - MANDATORY READING
196
+
197
+ - WCAG 2.1: https://www.w3.org/WAI/WCAG21/quickref/
198
+ - ARIA Authoring Practices: https://www.w3.org/WAI/ARIA/apg/
199
+ - WebAIM: https://webaim.org/