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,280 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ ---
6
+
7
+ # Testing Standards - STRICT (90% Coverage Minimum)
8
+
9
+ ## Testing Philosophy - ZERO TOLERANCE
10
+
11
+ - 90% coverage MINIMUM (not 80%)
12
+ - ALL new code MUST have tests before PR
13
+ - Tests are NOT optional
14
+ - Coverage decrease = automatic PR rejection
15
+ - Flaky tests = automatic PR rejection
16
+ - Tests MUST catch real bugs
17
+
18
+ ## Coverage Requirements - MANDATORY
19
+
20
+ ### Minimum Coverage - HARD LIMITS
21
+
22
+ - Overall coverage: 90% (no exceptions)
23
+ - Statement coverage: 90%
24
+ - Branch coverage: 85%
25
+ - Function coverage: 90%
26
+ - Line coverage: 90%
27
+ - Components: 100% coverage REQUIRED
28
+
29
+ ### Coverage Enforcement
30
+
31
+ - CI/CD blocks merge if coverage < 90%
32
+ - Coverage reports REQUIRED in every PR
33
+ - Coverage badge MUST be green
34
+ - Coverage decrease by >1% = automatic rejection
35
+
36
+ ## Unit Testing - STRICT STANDARDS
37
+
38
+ ### What MUST Be Tested - ALL REQUIRED
39
+
40
+ - ALL exported functions
41
+ - ALL components (100% coverage)
42
+ - ALL conditional logic paths
43
+ - ALL event handlers
44
+ - ALL hooks (custom and standard)
45
+ - ALL error states
46
+ - ALL loading states
47
+ - ALL edge cases
48
+
49
+ ### What NOT to Test
50
+
51
+ - Third-party library internals ONLY
52
+ - Trivial getters/setters ONLY if truly trivial
53
+ - Constants (unless computed)
54
+
55
+ ### Test Structure - MANDATORY FORMAT
56
+
57
+ ```typescript
58
+ describe("ComponentName", () => {
59
+ // Setup
60
+ let wrapper: ShallowWrapper;
61
+ let props: Props;
62
+
63
+ beforeEach(() => {
64
+ props = {
65
+ // complete props with realistic values
66
+ };
67
+ });
68
+
69
+ afterEach(() => {
70
+ jest.clearAllMocks();
71
+ });
72
+
73
+ afterAll(() => {
74
+ jest.restoreAllMocks();
75
+ });
76
+
77
+ // Tests grouped by functionality
78
+ describe("rendering", () => {
79
+ it("should render with required props only", () => {
80
+ wrapper = shallow(<ComponentName {...props} />);
81
+ expect(wrapper.exists()).toBe(true);
82
+ });
83
+
84
+ it("should display title when provided", () => {
85
+ wrapper = shallow(<ComponentName {...props} title="Test" />);
86
+ expect(wrapper.find(".title").text()).toBe("Test");
87
+ });
88
+ });
89
+
90
+ describe("user interactions", () => {
91
+ it("should call onClick handler when button clicked", () => {
92
+ const mockOnClick = jest.fn();
93
+ wrapper = shallow(<ComponentName {...props} onClick={mockOnClick} />);
94
+
95
+ wrapper.find("button").simulate("click");
96
+
97
+ expect(mockOnClick).toHaveBeenCalledTimes(1);
98
+ expect(mockOnClick).toHaveBeenCalledWith(/* expected args */);
99
+ });
100
+ });
101
+
102
+ describe("error handling", () => {
103
+ it("should display error message when error prop provided", () => {
104
+ wrapper = shallow(<ComponentName {...props} error="Error occurred" />);
105
+ expect(wrapper.find(".error").text()).toBe("Error occurred");
106
+ });
107
+ });
108
+ });
109
+ ```
110
+
111
+ ### Test Naming - STRICT REQUIREMENTS
112
+
113
+ - Format: "should [expected behavior] when [condition]"
114
+ - Be SPECIFIC (no "works correctly", "renders", "is defined")
115
+ - Test names MUST describe user behavior
116
+
117
+ ```typescript
118
+ // CORRECT
119
+ it("should disable submit button when form is invalid", () => {});
120
+ it("should display error message when API call fails", () => {});
121
+ it("should focus input when modal opens", () => {});
122
+
123
+ // INCORRECT - TOO VAGUE
124
+ it("works", () => {}); // REJECTED
125
+ it("renders correctly", () => {}); // REJECTED
126
+ it("handles errors", () => {}); // REJECTED
127
+ ```
128
+
129
+ ## Component Testing - 100% COVERAGE REQUIRED
130
+
131
+ ### ALL These MUST Be Tested
132
+
133
+ - Rendering with all prop combinations
134
+ - All conditional rendering paths
135
+ - All event handlers
136
+ - All state changes
137
+ - All hooks and their effects
138
+ - All error boundaries
139
+ - All loading states
140
+ - Accessibility (keyboard, ARIA)
141
+
142
+ ### Rendering Tests - MANDATORY
143
+
144
+ ```typescript
145
+ // Test all prop combinations
146
+ it("should render with minimal props", () => {});
147
+ it("should render with all optional props", () => {});
148
+ it("should render in loading state", () => {});
149
+ it("should render in error state", () => {});
150
+ it("should render when data is empty", () => {});
151
+ it("should render when data is populated", () => {});
152
+ ```
153
+
154
+ ### Interaction Tests - ALL REQUIRED
155
+
156
+ ```typescript
157
+ // Test ALL user interactions
158
+ it("should call onClick when button clicked", () => {});
159
+ it("should prevent default on form submit", () => {});
160
+ it("should update state when input changes", () => {});
161
+ it("should call onSubmit with form data", () => {});
162
+ it("should focus input on mount", () => {});
163
+ it("should trap focus in modal", () => {});
164
+ ```
165
+
166
+ ### Accessibility Tests - MANDATORY
167
+
168
+ ```typescript
169
+ // Test keyboard navigation
170
+ it("should be focusable with Tab key", () => {});
171
+ it("should activate with Enter key", () => {});
172
+ it("should close with Escape key", () => {});
173
+
174
+ // Test ARIA attributes
175
+ it("should have correct aria-label", () => {});
176
+ it("should announce errors to screen readers", () => {});
177
+ it("should have proper role attribute", () => {});
178
+ ```
179
+
180
+ ## Hooks Testing - STRICT REQUIREMENTS
181
+
182
+ ### Custom Hooks - 100% Coverage
183
+
184
+ ```typescript
185
+ import { renderHook, act } from "@testing-library/react-hooks";
186
+
187
+ describe("useCustomHook", () => {
188
+ it("should initialize with default value", () => {
189
+ const { result } = renderHook(() => useCustomHook());
190
+ expect(result.current.value).toBe(defaultValue);
191
+ });
192
+
193
+ it("should update value when action called", () => {
194
+ const { result } = renderHook(() => useCustomHook());
195
+
196
+ act(() => {
197
+ result.current.updateValue(newValue);
198
+ });
199
+
200
+ expect(result.current.value).toBe(newValue);
201
+ });
202
+
203
+ it("should cleanup on unmount", () => {
204
+ const cleanup = jest.fn();
205
+ const { unmount } = renderHook(() => useCustomHook(cleanup));
206
+
207
+ unmount();
208
+
209
+ expect(cleanup).toHaveBeenCalledTimes(1);
210
+ });
211
+ });
212
+ ```
213
+
214
+ ## Mocking - STRICT STANDARDS
215
+
216
+ ### MUST Mock These
217
+
218
+ - All external API calls
219
+ - ALL Redux store and actions
220
+ - ALL browser APIs (localStorage, window, document)
221
+ - ALL third-party libraries
222
+ - ALL time-dependent functions (Date, moment)
223
+ - ALL file system operations
224
+ - ALL network requests
225
+
226
+ ### Mock Pattern - MANDATORY
227
+
228
+ ```typescript
229
+ // Mock at top of file
230
+ jest.mock("../utils/api", () => ({
231
+ fetchData: jest.fn(),
232
+ postData: jest.fn(),
233
+ }));
234
+
235
+ // Use in tests
236
+ import { fetchData } from "../utils/api";
237
+
238
+ describe("Component", () => {
239
+ beforeEach(() => {
240
+ (fetchData as jest.Mock).mockResolvedValue({ data: "test" });
241
+ });
242
+
243
+ afterEach(() => {
244
+ jest.clearAllMocks();
245
+ });
246
+
247
+ afterAll(() => {
248
+ jest.restoreAllMocks();
249
+ });
250
+ });
251
+ ```
252
+
253
+ ### What NOT to Mock
254
+
255
+ - Component's own functions (test real behavior)
256
+ - Simple utility functions (test actual implementation)
257
+ - React internals (useState, useEffect, etc.)
258
+ - PropTypes validation
259
+
260
+ ## Test Quality - STRICT ENFORCEMENT
261
+
262
+ ### Prohibited - AUTOMATIC REJECTION
263
+
264
+ - NO snapshot tests (explicit assertions ONLY)
265
+ - NO test.skip in committed code
266
+ - NO test.only in committed code
267
+ - NO fit or fdescribe
268
+ - NO flaky tests (must pass 100% of time)
269
+ - NO setTimeout > 100ms
270
+ - NO tests depending on execution order
271
+ - NO tests with side effects
272
+
273
+ ### Required - ALL MANDATORY
274
+
275
+ - Descriptive test names
276
+ - Arrange-Act-Assert pattern
277
+ - Independent tests (no shared state)
278
+ - Fast tests (<100ms per test)
279
+ - Deterministic tests (same input = same output)
280
+ - Isolated tests (mock external dependencies)
@@ -0,0 +1,48 @@
1
+ # Agentic Code Standards - Minimal Profile
2
+
3
+ # Version: 1.0.0
4
+
5
+ # Profile: Essential rules only - great for getting started
6
+
7
+ ## Core Principles
8
+
9
+ - Write clean, readable code
10
+ - Follow basic accessibility guidelines
11
+ - Use modern JavaScript/TypeScript patterns
12
+
13
+ ## Accessibility Basics
14
+
15
+ - All interactive elements must be keyboard accessible (Tab, Enter, Space)
16
+ - Provide alt text for images that convey information
17
+ - Use semantic HTML elements (button, nav, main, header, footer)
18
+ - Minimum color contrast: 4.5:1 for normal text
19
+
20
+ ## Code Quality
21
+
22
+ - Use descriptive variable and function names
23
+ - Prefer `const` over `let`, never use `var`
24
+ - Keep functions small and focused (under 50 lines)
25
+ - Remove `console.log` statements before committing
26
+
27
+ ## React Essentials
28
+
29
+ - Use functional components with hooks
30
+ - Destructure props: `const Component = ({prop1, prop2}) => {}`
31
+ - Extract reusable logic into custom hooks
32
+ - Keep components under 200 lines
33
+
34
+ ## Testing
35
+
36
+ - Write tests for critical functionality
37
+ - Test user behavior, not implementation details
38
+ - Mock external dependencies
39
+
40
+ ## Security
41
+
42
+ - Never commit API keys or secrets
43
+ - Validate user inputs
44
+ - Use environment variables for configuration
45
+
46
+ ---
47
+
48
+ Learn more: https://github.com/netshdev/codingwithagent
@@ -0,0 +1,40 @@
1
+ # Minimal Profile
2
+
3
+ Essential coding standards for getting started with AI agents.
4
+
5
+ ## What's Included
6
+
7
+ - Basic accessibility requirements
8
+ - Naming conventions
9
+ - React component basics
10
+ - Code quality essentials
11
+
12
+ ## Best For
13
+
14
+ - Small projects
15
+ - Getting started
16
+ - Rapid prototyping
17
+ - Personal projects
18
+
19
+ ## Coverage
20
+
21
+ - Keyboard navigation
22
+ - Alt text for images
23
+ - Semantic HTML
24
+ - Basic React patterns
25
+
26
+ ## Quick Start
27
+
28
+ ```bash
29
+ npx codingwithagent init
30
+ # Select: 1. Minimal
31
+ ```
32
+
33
+ ### What you get
34
+
35
+ A `.cursorrules` file with the rules focusing on:
36
+
37
+ - Clean, readable code
38
+ - Basic accessibility compliance
39
+ - Modern JavaScript patterns
40
+ - Simple React best practices
@@ -0,0 +1,184 @@
1
+ # Agentic Code Standards - Standard Profile
2
+
3
+ # Version: 1.0.0
4
+
5
+ # Profile: Recommended baseline for production code ⭐
6
+
7
+ ## Core Principles
8
+
9
+ - Write accessible, maintainable, and secure code
10
+ - Follow WCAG 2.1 Level AA standards
11
+ - Use modern JavaScript/TypeScript patterns
12
+ - Test thoroughly, document clearly
13
+
14
+ ## Accessibility Standards
15
+
16
+ ### Keyboard Navigation
17
+
18
+ - All interactive elements must be keyboard accessible
19
+ - Support Tab, Enter, Space, Escape keys
20
+ - Visible focus indicators required
21
+ - Never use `tabIndex > 0`
22
+
23
+ ### Screen Readers
24
+
25
+ - Use semantic HTML (header, nav, main, footer, button)
26
+ - Provide meaningful alt text for images
27
+ - Use ARIA labels only when semantic HTML isn't enough
28
+ - Test with screen readers (NVDA, JAWS, VoiceOver)
29
+
30
+ ### Visual Accessibility
31
+
32
+ - Minimum contrast ratio: 4.5:1 for normal text, 3:1 for large text
33
+ - Never use color alone to convey information
34
+ - Support text resize up to 200%
35
+ - Interactive elements minimum size: 24x24 pixels
36
+
37
+ ### Forms
38
+
39
+ - All form fields must have associated labels
40
+ - Provide clear error messages
41
+ - Indicate required fields
42
+ - Support keyboard navigation throughout
43
+
44
+ ## React & Components
45
+
46
+ ### Component Structure
47
+
48
+ - Use functional components with hooks (not class components)
49
+ - Destructure props at function signature: `const Component = ({prop1, prop2}) => {}`
50
+ - Keep components under 200 lines - refactor if longer
51
+ - One component per file (except small helper components)
52
+
53
+ ### Props & State
54
+
55
+ - Define PropTypes for all components
56
+ - Mark required props with `.isRequired`
57
+ - Use TypeScript for type safety
58
+ - Local state for UI only, Redux/context for shared data
59
+ - Avoid prop drilling beyond 3 levels
60
+
61
+ ### Hooks Best Practices
62
+
63
+ - `useState`: UI-only state (modals, toggles)
64
+ - `useEffect`: Side effects, subscriptions, API calls
65
+ - Always specify dependencies array
66
+ - Return cleanup functions for subscriptions
67
+ - `useMemo`: Expensive calculations only
68
+ - `useCallback`: Prevent unnecessary re-renders
69
+ - `useRef`: DOM access, mutable values that don't trigger re-renders
70
+
71
+ ### JSX Standards
72
+
73
+ - No anonymous functions in render: `onClick={handleClick}` not `onClick={() => handleClick()}`
74
+ - Use fragments `<></>` instead of unnecessary divs
75
+ - Keys from data, not array index: `key={item.id}` not `key={index}`
76
+ - Conditional rendering with boolean values only
77
+ - Extract complex JSX to separate components
78
+
79
+ ## Code Quality
80
+
81
+ ### JavaScript/TypeScript
82
+
83
+ - Use TypeScript for type safety
84
+ - Prefer `const` over `let`, never use `var`
85
+ - Use arrow functions for callbacks
86
+ - Destructure objects and arrays
87
+ - Use template literals for string interpolation
88
+ - Async/await instead of promise chains
89
+
90
+ ### Naming Conventions
91
+
92
+ - Variables & functions: `camelCase` (getUserData)
93
+ - Components: `PascalCase` (UserProfile)
94
+ - Constants: `UPPER_SNAKE_CASE` (MAX_RETRIES)
95
+ - Files: `kebab-case` (user-profile.jsx)
96
+ - Be descriptive: `isUserAuthenticated` not `isAuth`
97
+
98
+ ### Functions
99
+
100
+ - Pure functions when possible (no side effects)
101
+ - Maximum function length: 50 lines
102
+ - Single responsibility principle
103
+ - Return early to reduce nesting
104
+ - Use meaningful parameter names
105
+
106
+ ### Prohibited Patterns
107
+
108
+ - No `console.log` in production code
109
+ - No `window` object access (use approved utilities)
110
+ - No `eslint-disable` without team approval
111
+ - No direct DOM manipulation (use React refs if needed)
112
+ - No inline styles (use CSS/styled-components)
113
+
114
+ ## Testing Standards
115
+
116
+ ### Coverage Requirements
117
+
118
+ - Aim for 80%+ coverage on new code
119
+ - All new features must have tests
120
+ - Test user behavior, not implementation
121
+ - Use descriptive test names
122
+
123
+ ### Testing Best Practices
124
+
125
+ - Shallow render preferred (use mount only for hooks)
126
+ - Mock external dependencies (APIs, Redux, third-party libs)
127
+ - Clean up mocks with `afterEach(() => jest.clearAllMocks())`
128
+ - Avoid snapshots (explicit assertions preferred)
129
+ - Test accessibility (keyboard nav, ARIA labels)
130
+
131
+ ## Security
132
+
133
+ ### Data Protection
134
+
135
+ - Never commit secrets, API keys, or credentials
136
+ - Use environment variables for configuration
137
+ - Validate all user inputs
138
+ - Sanitize data before rendering
139
+ - Follow PII/PCI data handling guidelines
140
+
141
+ ### Dependencies
142
+
143
+ - Keep dependencies up to date
144
+ - Review security advisories regularly
145
+ - Audit third-party packages before use
146
+ - Minimize dependency count
147
+
148
+ ## Performance
149
+
150
+ ### Optimization
151
+
152
+ - Code splitting for large bundles
153
+ - Lazy load routes and components
154
+ - Memoize expensive calculations with `useMemo`
155
+ - Prevent unnecessary re-renders with `React.memo` and `useCallback`
156
+ - Optimize images (WebP, proper sizing)
157
+
158
+ ### Best Practices
159
+
160
+ - Avoid large component trees
161
+ - Debounce expensive operations
162
+ - Virtualize long lists
163
+ - Monitor bundle size
164
+
165
+ ## Pull Request Standards
166
+
167
+ ### Before Submitting
168
+
169
+ - All tests pass locally
170
+ - No linting errors
171
+ - Code coverage maintained or increased
172
+ - CHANGELOG.md updated
173
+ - Self-review completed
174
+
175
+ ### PR Description
176
+
177
+ - Clear title describing the change
178
+ - Reference related issues
179
+ - Include screenshots for UI changes
180
+ - List testing steps
181
+
182
+ ---
183
+
184
+ Full documentation: https://github.com/netshdev/codingwithagent
@@ -0,0 +1,43 @@
1
+ # Standard Profile ⭐
2
+
3
+ Recommended baseline for production applications. Most popular choice.
4
+
5
+ ## What's Included
6
+
7
+ - WCAG 2.1 Level AA accessibility
8
+ - Comprehensive React patterns
9
+ - Testing standards (80%+ coverage)
10
+ - Security best practices
11
+ - Performance guidelines
12
+
13
+ ## Best For
14
+
15
+ - Production applications
16
+ - Team projects
17
+ - Client work
18
+ - Long-term maintenance
19
+
20
+ ## Coverage
21
+
22
+ - Full keyboard accessibility
23
+ - Screen reader compatibility
24
+ - Component best practices
25
+ - Testing requirements
26
+ - Pull request standards
27
+
28
+ ## Quick Start
29
+
30
+ ```bash
31
+ npx codingwithagent init
32
+ # Select: 2. Standard
33
+ ```
34
+
35
+ ### What you get
36
+
37
+ A `.cursorrules` file with the rules focusing on:
38
+
39
+ - Accessibility (WCAG 2.1 AA)
40
+ - React & TypeScript
41
+ - Testing & coverage
42
+ - Security & PII
43
+ - Code quality & performance