@ranimontagna/agent-toolkit 0.1.6 → 0.1.7

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 (38) hide show
  1. package/README.md +28 -8
  2. package/package.json +1 -1
  3. package/skills/backend/go/golang-patterns/LICENSE +21 -0
  4. package/skills/backend/go/golang-patterns/NOTICE.md +10 -0
  5. package/skills/backend/go/golang-patterns/SKILL.md +674 -0
  6. package/skills/backend/go/golang-testing/LICENSE +21 -0
  7. package/skills/backend/go/golang-testing/NOTICE.md +10 -0
  8. package/skills/backend/go/golang-testing/SKILL.md +329 -0
  9. package/skills/backend/java/java-coding-standards/LICENSE +21 -0
  10. package/skills/backend/java/java-coding-standards/NOTICE.md +10 -0
  11. package/skills/backend/java/java-coding-standards/SKILL.md +383 -0
  12. package/skills/backend/java/java-junit/LICENSE +21 -0
  13. package/skills/backend/java/java-junit/NOTICE.md +10 -0
  14. package/skills/backend/java/java-junit/SKILL.md +64 -0
  15. package/skills/frontend/react/react-patterns/SKILL.md +4 -4
  16. package/skills/frontend/react/react-patterns/rules/react/LICENSE +21 -0
  17. package/skills/frontend/react/react-patterns/rules/react/NOTICE.md +11 -0
  18. package/skills/frontend/react/react-patterns/rules/react/coding-style.md +109 -0
  19. package/skills/frontend/react/react-patterns/rules/react/hooks.md +187 -0
  20. package/skills/frontend/react/react-patterns/rules/react/patterns.md +194 -0
  21. package/skills/frontend/react/react-patterns/rules/react/security.md +180 -0
  22. package/skills/frontend/react/react-patterns/rules/react/testing.md +208 -0
  23. package/skills/frontend/react/react-performance/SKILL.md +2 -2
  24. package/skills/frontend/react/react-performance/rules/react/LICENSE +21 -0
  25. package/skills/frontend/react/react-performance/rules/react/NOTICE.md +11 -0
  26. package/skills/frontend/react/react-performance/rules/react/coding-style.md +109 -0
  27. package/skills/frontend/react/react-performance/rules/react/hooks.md +187 -0
  28. package/skills/frontend/react/react-performance/rules/react/patterns.md +194 -0
  29. package/skills/frontend/react/react-performance/rules/react/security.md +180 -0
  30. package/skills/frontend/react/react-performance/rules/react/testing.md +208 -0
  31. package/skills/frontend/react/react-testing/SKILL.md +4 -4
  32. package/skills/frontend/react/react-testing/rules/react/LICENSE +21 -0
  33. package/skills/frontend/react/react-testing/rules/react/NOTICE.md +11 -0
  34. package/skills/frontend/react/react-testing/rules/react/coding-style.md +109 -0
  35. package/skills/frontend/react/react-testing/rules/react/hooks.md +187 -0
  36. package/skills/frontend/react/react-testing/rules/react/patterns.md +194 -0
  37. package/skills/frontend/react/react-testing/rules/react/security.md +180 -0
  38. package/skills/frontend/react/react-testing/rules/react/testing.md +208 -0
@@ -0,0 +1,383 @@
1
+ ---
2
+ name: java-coding-standards
3
+ description: "Use when writing or reviewing Java 17+ code in Spring Boot or Quarkus services, including naming, immutability, Optional usage, streams, exceptions, generics, CDI, reactive patterns, and project layout."
4
+ origin: ECC
5
+ ---
6
+
7
+ # Java Coding Standards
8
+
9
+ Standards for readable, maintainable Java (17+) code in Spring Boot and Quarkus services.
10
+
11
+ ## When to Use
12
+
13
+ - Writing or reviewing Java code in Spring Boot or Quarkus projects
14
+ - Enforcing naming, immutability, or exception handling conventions
15
+ - Working with records, sealed classes, or pattern matching (Java 17+)
16
+ - Reviewing use of Optional, streams, or generics
17
+ - Structuring packages and project layout
18
+ - **[QUARKUS]**: Working with CDI scopes, Panache entities, or reactive pipelines
19
+
20
+ ## How It Works
21
+
22
+ ### Framework Detection
23
+
24
+ Before applying standards, determine the framework from the build file:
25
+
26
+ - Build file contains `quarkus` → apply **[QUARKUS]** conventions
27
+ - Build file contains `spring-boot` → apply **[SPRING]** conventions
28
+ - Neither detected → apply shared conventions only
29
+
30
+ ## Core Principles
31
+
32
+ - Prefer clarity over cleverness
33
+ - Immutable by default; minimize shared mutable state
34
+ - Fail fast with meaningful exceptions
35
+ - Consistent naming and package structure
36
+ - **[QUARKUS]**: Favor build-time over runtime processing; avoid runtime reflection where possible
37
+
38
+ ## Examples
39
+
40
+ The sections below show concrete Spring Boot, Quarkus, and shared Java examples
41
+ for naming, immutability, dependency injection, reactive code, exceptions,
42
+ project layout, logging, configuration, and tests.
43
+
44
+ ## Naming
45
+
46
+ ```java
47
+ // PASS: Classes/Records: PascalCase
48
+ public class MarketService {}
49
+ public record Money(BigDecimal amount, Currency currency) {}
50
+
51
+ // PASS: Methods/fields: camelCase
52
+ private final MarketRepository marketRepository;
53
+ public Market findBySlug(String slug) {}
54
+
55
+ // PASS: Constants: UPPER_SNAKE_CASE
56
+ private static final int MAX_PAGE_SIZE = 100;
57
+
58
+ // PASS: [QUARKUS] JAX-RS resources named as *Resource, not *Controller
59
+ public class MarketResource {}
60
+
61
+ // PASS: [SPRING] REST controllers named as *Controller
62
+ public class MarketController {}
63
+ ```
64
+
65
+ ## Immutability
66
+
67
+ ```java
68
+ // PASS: Favor records and final fields
69
+ public record MarketDto(Long id, String name, MarketStatus status) {}
70
+
71
+ public class Market {
72
+ private final Long id;
73
+ private final String name;
74
+ // getters only, no setters
75
+ }
76
+
77
+ // PASS: [QUARKUS] Panache active-record entities use public fields (Quarkus convention)
78
+ @Entity
79
+ public class Market extends PanacheEntity {
80
+ public String name;
81
+ public MarketStatus status;
82
+ // Panache generates accessors at build time; public fields are idiomatic here
83
+ }
84
+
85
+ // PASS: [QUARKUS] Panache MongoDB entities
86
+ @MongoEntity(collection = "markets")
87
+ public class Market extends PanacheMongoEntity {
88
+ public String name;
89
+ public MarketStatus status;
90
+ }
91
+ ```
92
+
93
+ ## Optional Usage
94
+
95
+ ```java
96
+ // PASS: Return Optional from find* methods
97
+ // [SPRING]
98
+ Optional<Market> market = marketRepository.findBySlug(slug);
99
+
100
+ // [QUARKUS] Panache
101
+ Optional<Market> market = Market.find("slug", slug).firstResultOptional();
102
+
103
+ // PASS: Map/flatMap instead of get()
104
+ return market
105
+ .map(MarketResponse::from)
106
+ .orElseThrow(() -> new EntityNotFoundException("Market not found"));
107
+ ```
108
+
109
+ ## Streams Best Practices
110
+
111
+ ```java
112
+ // PASS: Use streams for transformations, keep pipelines short
113
+ List<String> names = markets.stream()
114
+ .map(Market::name)
115
+ .filter(Objects::nonNull)
116
+ .toList();
117
+
118
+ // FAIL: Avoid complex nested streams; prefer loops for clarity
119
+ ```
120
+
121
+ ## Dependency Injection
122
+
123
+ ```java
124
+ // PASS: [SPRING] Constructor injection (preferred over @Autowired on fields)
125
+ @Service
126
+ public class MarketService {
127
+ private final MarketRepository marketRepository;
128
+
129
+ public MarketService(MarketRepository marketRepository) {
130
+ this.marketRepository = marketRepository;
131
+ }
132
+ }
133
+
134
+ // PASS: [QUARKUS] Constructor injection
135
+ @ApplicationScoped
136
+ public class MarketService {
137
+ private final MarketRepository marketRepository;
138
+
139
+ @Inject
140
+ public MarketService(MarketRepository marketRepository) {
141
+ this.marketRepository = marketRepository;
142
+ }
143
+ }
144
+
145
+ // PASS: [QUARKUS] Package-private field injection (acceptable in Quarkus — avoids proxy issues)
146
+ @ApplicationScoped
147
+ public class MarketService {
148
+ @Inject
149
+ MarketRepository marketRepository;
150
+ }
151
+
152
+ // FAIL: [SPRING] Field injection with @Autowired
153
+ @Autowired
154
+ private MarketRepository marketRepository; // use constructor injection
155
+
156
+ // FAIL: [QUARKUS] @Singleton when interception or lazy init is needed
157
+ @Singleton // non-proxyable — use @ApplicationScoped instead
158
+ public class MarketService {}
159
+ ```
160
+
161
+ ## Reactive Patterns [QUARKUS]
162
+
163
+ ```java
164
+ // PASS: Return Uni/Multi from reactive endpoints
165
+ @GET
166
+ @Path("/{slug}")
167
+ public Uni<Market> findBySlug(@PathParam("slug") String slug) {
168
+ return Market.find("slug", slug)
169
+ .<Market>firstResult()
170
+ .onItem().ifNull().failWith(() -> new MarketNotFoundException(slug));
171
+ }
172
+
173
+ // PASS: Non-blocking pipeline composition
174
+ public Uni<OrderConfirmation> placeOrder(OrderRequest req) {
175
+ return validateOrder(req)
176
+ .chain(valid -> persistOrder(valid))
177
+ .chain(order -> notifyFulfillment(order));
178
+ }
179
+
180
+ // FAIL: Blocking call inside a Uni/Multi pipeline
181
+ public Uni<Market> find(String slug) {
182
+ Market m = Market.find("slug", slug).firstResult(); // BLOCKING — breaks event loop
183
+ return Uni.createFrom().item(m);
184
+ }
185
+
186
+ // FAIL: Subscribing more than once to a shared Uni
187
+ Uni<Market> shared = fetchMarket(slug);
188
+ shared.subscribe().with(m -> log(m));
189
+ shared.subscribe().with(m -> cache(m)); // double subscribe — use Uni.memoize()
190
+ ```
191
+
192
+ ## Exceptions
193
+
194
+ - Use unchecked exceptions for domain errors; wrap technical exceptions with context
195
+ - Create domain-specific exceptions (e.g., `MarketNotFoundException`)
196
+ - Avoid broad `catch (Exception ex)` unless rethrowing/logging centrally
197
+
198
+ ```java
199
+ throw new MarketNotFoundException(slug);
200
+ ```
201
+
202
+ ### Centralised Exception Handling
203
+
204
+ ```java
205
+ // [SPRING]
206
+ @RestControllerAdvice
207
+ public class GlobalExceptionHandler {
208
+ @ExceptionHandler(MarketNotFoundException.class)
209
+ public ResponseEntity<ErrorResponse> handle(MarketNotFoundException ex) {
210
+ return ResponseEntity.status(404).body(ErrorResponse.from(ex));
211
+ }
212
+ }
213
+
214
+ // [QUARKUS] Option A: ExceptionMapper
215
+ @Provider
216
+ public class MarketNotFoundMapper implements ExceptionMapper<MarketNotFoundException> {
217
+ @Override
218
+ public Response toResponse(MarketNotFoundException ex) {
219
+ return Response.status(404).entity(ErrorResponse.from(ex)).build();
220
+ }
221
+ }
222
+
223
+ // [QUARKUS] Option B: @ServerExceptionMapper (RESTEasy Reactive)
224
+ @ServerExceptionMapper
225
+ public RestResponse<ErrorResponse> handle(MarketNotFoundException ex) {
226
+ return RestResponse.status(Status.NOT_FOUND, ErrorResponse.from(ex));
227
+ }
228
+ ```
229
+
230
+ ## Generics and Type Safety
231
+
232
+ - Avoid raw types; declare generic parameters
233
+ - Prefer bounded generics for reusable utilities
234
+
235
+ ```java
236
+ public <T extends Identifiable> Map<Long, T> indexById(Collection<T> items) { ... }
237
+ ```
238
+
239
+ ## Project Structure
240
+
241
+ ### [SPRING] Maven/Gradle
242
+
243
+ ```
244
+ src/main/java/com/example/app/
245
+ config/
246
+ controller/
247
+ service/
248
+ repository/
249
+ domain/
250
+ dto/
251
+ util/
252
+ src/main/resources/
253
+ application.yml
254
+ src/test/java/... (mirrors main)
255
+ ```
256
+
257
+ ### [QUARKUS] Maven/Gradle
258
+
259
+ ```
260
+ src/main/java/com/example/app/
261
+ config/ # @ConfigMapping, @ConfigProperty beans, Producers
262
+ resource/ # JAX-RS resources (not "controller")
263
+ service/
264
+ repository/ # PanacheRepository implementations (if not using active record)
265
+ domain/ # JPA/Panache entities, MongoDB entities
266
+ dto/
267
+ util/
268
+ mapper/ # MapStruct mappers (if used)
269
+ src/main/resources/
270
+ application.properties # Quarkus convention (YAML supported with quarkus-config-yaml)
271
+ import.sql # Hibernate auto-import for dev/test
272
+ src/test/java/... (mirrors main)
273
+ ```
274
+
275
+ ## Formatting and Style
276
+
277
+ - Use 2 or 4 spaces consistently (project standard)
278
+ - One public top-level type per file
279
+ - Keep methods short and focused; extract helpers
280
+ - Order members: constants, fields, constructors, public methods, protected, private
281
+
282
+ ## Code Smells to Avoid
283
+
284
+ - Long parameter lists → use DTO/builders
285
+ - Deep nesting → early returns
286
+ - Magic numbers → named constants
287
+ - Static mutable state → prefer dependency injection
288
+ - Silent catch blocks → log and act or rethrow
289
+ - **[QUARKUS]**: `@Singleton` where `@ApplicationScoped` is intended — breaks proxying and interception
290
+ - **[QUARKUS]**: Mixing `quarkus-resteasy-reactive` and `quarkus-resteasy` (classic) — pick one stack
291
+ - **[QUARKUS]**: Panache active-record + repository pattern in the same bounded context — pick one
292
+
293
+ ## Logging
294
+
295
+ ```java
296
+ // [SPRING] SLF4J
297
+ private static final Logger log = LoggerFactory.getLogger(MarketService.class);
298
+ log.info("fetch_market slug={}", slug);
299
+ log.error("failed_fetch_market slug={}", slug, ex);
300
+
301
+ // [QUARKUS] JBoss Logging (default, zero-cost at build time)
302
+ private static final Logger log = Logger.getLogger(MarketService.class);
303
+ log.infof("fetch_market slug=%s", slug);
304
+ log.errorf(ex, "failed_fetch_market slug=%s", slug);
305
+
306
+ // [QUARKUS] Alternative: simplified logging with @Inject
307
+ @Inject
308
+ Logger log; // CDI-injected, scoped to declaring class
309
+ ```
310
+
311
+ ## Null Handling
312
+
313
+ - Accept `@Nullable` only when unavoidable; otherwise use `@NonNull`
314
+ - Use Bean Validation (`@NotNull`, `@NotBlank`) on inputs
315
+ - **[QUARKUS]**: Apply `@Valid` on `@BeanParam`, `@RestForm`, and request body parameters
316
+
317
+ ## Configuration
318
+
319
+ ```java
320
+ // [SPRING] @ConfigurationProperties
321
+ @ConfigurationProperties(prefix = "market")
322
+ public record MarketProperties(int maxPageSize, Duration cacheTtl) {}
323
+
324
+ // [QUARKUS] @ConfigMapping (type-safe, build-time validated)
325
+ @ConfigMapping(prefix = "market")
326
+ public interface MarketConfig {
327
+ int maxPageSize();
328
+ Duration cacheTtl();
329
+ }
330
+
331
+ // [QUARKUS] Simple values with @ConfigProperty
332
+ @ConfigProperty(name = "market.max-page-size", defaultValue = "100")
333
+ int maxPageSize;
334
+ ```
335
+
336
+ ## Testing Expectations
337
+
338
+ ### Shared
339
+ - JUnit 5 + AssertJ for fluent assertions
340
+ - Mockito for mocking; avoid partial mocks where possible
341
+ - Favor deterministic tests; no hidden sleeps
342
+
343
+ ### [SPRING]
344
+ - `@WebMvcTest` for controller slices, `@DataJpaTest` for repository slices
345
+ - `@SpringBootTest` reserved for full integration tests
346
+ - `@MockBean` for replacing beans in Spring context
347
+
348
+ ### [QUARKUS]
349
+ - Plain JUnit 5 + Mockito for unit tests (no `@QuarkusTest`)
350
+ - `@QuarkusTest` reserved for CDI integration tests
351
+ - `@InjectMock` for replacing CDI beans in integration tests
352
+ - Dev Services for database/Kafka/Redis — avoid manual Testcontainers setup when Dev Services suffice
353
+ - `@QuarkusTestResource` for custom external service lifecycle
354
+
355
+ ```java
356
+ // [SPRING] Controller test
357
+ @WebMvcTest(MarketController.class)
358
+ class MarketControllerTest {
359
+ @Autowired MockMvc mockMvc;
360
+ @MockBean MarketService marketService;
361
+ }
362
+
363
+ // [QUARKUS] Integration test
364
+ @QuarkusTest
365
+ class MarketResourceTest {
366
+ @InjectMock
367
+ MarketService marketService;
368
+
369
+ @Test
370
+ void should_return_404_when_market_not_found() {
371
+ given().when().get("/markets/unknown").then().statusCode(404);
372
+ }
373
+ }
374
+
375
+ // [QUARKUS] Unit test (no CDI, no @QuarkusTest)
376
+ @ExtendWith(MockitoExtension.class)
377
+ class MarketServiceTest {
378
+ @Mock MarketRepository marketRepository;
379
+ @InjectMocks MarketService marketService;
380
+ }
381
+ ```
382
+
383
+ **Remember**: Keep code intentional, typed, and observable. Optimize for maintainability over micro-optimizations unless proven necessary.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright GitHub, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ # Third-party notice
2
+
3
+ This skill was copied from GitHub's awesome-copilot repository.
4
+
5
+ - Source: https://github.com/github/awesome-copilot/tree/main/skills/java-junit
6
+ - Source commit: 776d84143238cb91f7242665f188887b9e8d2aa9
7
+ - License: MIT
8
+ - Copyright: Copyright GitHub, Inc.
9
+
10
+ The upstream MIT license is included in `LICENSE`.
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: java-junit
3
+ description: Use when writing or improving JUnit 5 unit tests, including parameterized and data-driven tests.
4
+ origin: awesome-copilot
5
+ ---
6
+
7
+ # JUnit 5+ Best Practices
8
+
9
+ Your goal is to help me write effective unit tests with JUnit 5, covering both standard and data-driven testing approaches.
10
+
11
+ ## Project Setup
12
+
13
+ - Use a standard Maven or Gradle project structure.
14
+ - Place test source code in `src/test/java`.
15
+ - Include dependencies for `junit-jupiter-api`, `junit-jupiter-engine`, and `junit-jupiter-params` for parameterized tests.
16
+ - Use build tool commands to run tests: `mvn test` or `gradle test`.
17
+
18
+ ## Test Structure
19
+
20
+ - Test classes should have a `Test` suffix, e.g., `CalculatorTest` for a `Calculator` class.
21
+ - Use `@Test` for test methods.
22
+ - Follow the Arrange-Act-Assert (AAA) pattern.
23
+ - Name tests using a descriptive convention, like `methodName_should_expectedBehavior_when_scenario`.
24
+ - Use `@BeforeEach` and `@AfterEach` for per-test setup and teardown.
25
+ - Use `@BeforeAll` and `@AfterAll` for per-class setup and teardown (must be static methods).
26
+ - Use `@DisplayName` to provide a human-readable name for test classes and methods.
27
+
28
+ ## Standard Tests
29
+
30
+ - Keep tests focused on a single behavior.
31
+ - Avoid testing multiple conditions in one test method.
32
+ - Make tests independent and idempotent (can run in any order).
33
+ - Avoid test interdependencies.
34
+
35
+ ## Data-Driven (Parameterized) Tests
36
+
37
+ - Use `@ParameterizedTest` to mark a method as a parameterized test.
38
+ - Use `@ValueSource` for simple literal values (strings, ints, etc.).
39
+ - Use `@MethodSource` to refer to a factory method that provides test arguments as a `Stream`, `Collection`, etc.
40
+ - Use `@CsvSource` for inline comma-separated values.
41
+ - Use `@CsvFileSource` to use a CSV file from the classpath.
42
+ - Use `@EnumSource` to use enum constants.
43
+
44
+ ## Assertions
45
+
46
+ - Use the static methods from `org.junit.jupiter.api.Assertions` (e.g., `assertEquals`, `assertTrue`, `assertNotNull`).
47
+ - For more fluent and readable assertions, consider using a library like AssertJ (`assertThat(...).is...`).
48
+ - Use `assertThrows` or `assertDoesNotThrow` to test for exceptions.
49
+ - Group related assertions with `assertAll` to ensure all assertions are checked before the test fails.
50
+ - Use descriptive messages in assertions to provide clarity on failure.
51
+
52
+ ## Mocking and Isolation
53
+
54
+ - Use a mocking framework like Mockito to create mock objects for dependencies.
55
+ - Use `@Mock` and `@InjectMocks` annotations from Mockito to simplify mock creation and injection.
56
+ - Use interfaces to facilitate mocking.
57
+
58
+ ## Test Organization
59
+
60
+ - Group tests by feature or component using packages.
61
+ - Use `@Tag` to categorize tests (e.g., `@Tag("fast")`, `@Tag("integration")`).
62
+ - Use `@TestMethodOrder(MethodOrderer.OrderAnnotation.class)` and `@Order` to control test execution order when strictly necessary.
63
+ - Use `@Disabled` to temporarily skip a test method or class, providing a reason.
64
+ - Use `@Nested` to group tests in a nested inner class for better organization and structure.
@@ -52,7 +52,7 @@ React has no inheritance model for components. Compose with `children`, render p
52
52
 
53
53
  ## Hooks Discipline
54
54
 
55
- See [rules/react/hooks.md](../../rules/react/hooks.md) for the full ruleset. Highlights:
55
+ See [rules/react/hooks.md](rules/react/hooks.md) for the full ruleset. Highlights:
56
56
 
57
57
  - Top-level only, never conditional
58
58
  - Cleanup every subscription, interval, listener
@@ -250,7 +250,7 @@ Wrap a component in `React.memo` only when:
250
250
  - Form inputs need labels — `<label htmlFor>` or `aria-label` if visually labeled by an icon
251
251
  - Manage focus on route changes and modal open/close
252
252
  - Run `axe` in component tests (see [skills/react-testing](../react-testing/SKILL.md))
253
- - Cross-link: [skills/accessibility/SKILL.md](../accessibility/SKILL.md) covers WCAG criteria and pattern libraries
253
+ - Cross-link: skills/accessibility covers WCAG criteria and pattern libraries when that optional skill is installed
254
254
 
255
255
  ## Routing
256
256
 
@@ -264,8 +264,8 @@ This skill is router-agnostic. The patterns above work with React Router, TanSta
264
264
 
265
265
  ## Related
266
266
 
267
- - Rules: [rules/react/](../../rules/react/) — coding-style, hooks, patterns, security, testing
268
- - Skills: [react-performance](../react-performance/SKILL.md) for the Vercel-derived performance ruleset, [frontend-patterns](../frontend-patterns/SKILL.md) for cross-framework UI concerns, [accessibility](../accessibility/SKILL.md), [angular-developer](../angular-developer/SKILL.md) for framework comparison
267
+ - Rules: [rules/react/](rules/react/) — coding-style, hooks, patterns, security, testing
268
+ - Skills: [react-performance](../react-performance/SKILL.md) for the Vercel-derived performance ruleset; frontend-patterns for cross-framework UI concerns; accessibility; angular-developer for framework comparison
269
269
  - Agents: `react-reviewer` for code review, `react-build-resolver` for build/bundler errors
270
270
  - Commands: `/react-review`, `/react-build`, `/react-test`
271
271
 
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Affaan Mustafa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,11 @@
1
+ # Third-party notice
2
+
3
+ This directory contains React rule references copied from Affaan Mustafa's ECC
4
+ repository.
5
+
6
+ - Source: https://github.com/affaan-m/ECC/tree/main/rules/react
7
+ - Source commit: 0f84c0e2796703fbda87d577b2636351418c7442
8
+ - License: MIT
9
+ - Copyright: Copyright (c) 2026 Affaan Mustafa
10
+
11
+ The upstream MIT license is included in `LICENSE`.
@@ -0,0 +1,109 @@
1
+ ---
2
+ paths:
3
+ - "**/*.tsx"
4
+ - "**/*.jsx"
5
+ - "**/components/**/*.ts"
6
+ - "**/components/**/*.js"
7
+ - "**/hooks/**/*.ts"
8
+ - "**/hooks/**/*.js"
9
+ ---
10
+ # React Coding Style
11
+
12
+ > This file extends the upstream `typescript/coding-style.md` and `common/coding-style.md` rules with React specific content.
13
+
14
+ ## File Extensions
15
+
16
+ - `.tsx` for any file containing JSX, even one-liner snippets
17
+ - `.ts` for pure logic, custom hooks without JSX, type definitions, utilities
18
+ - `.test.tsx` / `.test.ts` mirroring the source file
19
+ - Use `.jsx` only when the project intentionally avoids TypeScript — flag every new untyped React file in review
20
+
21
+ ## Naming
22
+
23
+ - Components: `PascalCase` for both the symbol and the file (`UserCard.tsx`, default export `UserCard`)
24
+ - Custom hooks: `useCamelCase` for the symbol, kebab-case for the file when the project convention is kebab-case (`use-debounce.ts` exports `useDebounce`)
25
+ - Context: `<Domain>Context` symbol, `<Domain>Provider` provider component, `use<Domain>` consumer hook
26
+ - Event handlers: `handleClick`, `handleSubmit` inside the component; the prop that receives it is `onClick`, `onSubmit`
27
+ - Boolean props: `isLoading`, `hasError`, `canSubmit` — never `loading` or `error` alone for booleans
28
+
29
+ ## Component Shape
30
+
31
+ ```tsx
32
+ type Props = {
33
+ user: User;
34
+ onSelect: (id: string) => void;
35
+ };
36
+
37
+ export function UserCard({ user, onSelect }: Props) {
38
+ return (
39
+ <button type="button" onClick={() => onSelect(user.id)}>
40
+ {user.name}
41
+ </button>
42
+ );
43
+ }
44
+ ```
45
+
46
+ - Prefer `type Props = {}` for closed component prop shapes
47
+ - Use `interface` only when the prop type is extended via declaration merging or exported as a public API extension point
48
+ - Always destructure props in the parameter list — no `props.user` access inside the body
49
+ - Type the return implicitly through JSX (`function Foo(): JSX.Element` only when the function returns conditionally and the union confuses inference)
50
+
51
+ ## JSX
52
+
53
+ - Self-close tags with no children: `<img />`, `<UserCard user={u} />`
54
+ - Use fragments `<>...</>` over wrapper `<div>` when no DOM element is needed
55
+ - Conditional rendering: `{condition && <Foo />}` for booleans, ternary for either/or, early return for guard clauses
56
+ - Never put logic inline in JSX when it reads as multi-line — extract to a const above the return or a function
57
+
58
+ ```tsx
59
+ // Prefer
60
+ const greeting = user.isAdmin ? "Welcome, admin" : `Hello ${user.name}`;
61
+ return <h1>{greeting}</h1>;
62
+
63
+ // Over
64
+ return <h1>{user.isAdmin ? "Welcome, admin" : `Hello ${user.name}`}</h1>;
65
+ ```
66
+
67
+ ## Server / Client Boundary (Next.js App Router, RSC)
68
+
69
+ - Default a new file to Server Component — only add `"use client"` when the file uses state, effects, refs, browser APIs, or event handlers
70
+ - Place the `"use client"` directive on line 1, before any imports
71
+ - Never import a Client Component file from inside a `"use server"` action file
72
+ - Never re-export server-only code through a client module — the bundler will silently include it
73
+
74
+ ## Imports
75
+
76
+ - React imports first: `import { useState } from "react"`
77
+ - Then third-party libs, then absolute project imports, then relative
78
+ - Type-only imports: `import type { ReactNode } from "react"` — never mix runtime and type imports in one statement when ESLint's `consistent-type-imports` is configured
79
+
80
+ ## Hooks Discipline
81
+
82
+ See [hooks.md](./hooks.md) for the full ruleset. Style highlights:
83
+
84
+ - Custom hooks must start with `use` — enforced by `eslint-plugin-react-hooks`
85
+ - Group all hook calls at the top of the component, before any conditional logic
86
+ - Avoid creating ad-hoc hooks for one-line wrappers — inline the call instead
87
+
88
+ ## State
89
+
90
+ - Local first (`useState`), lift only when shared
91
+ - Context for cross-cutting state read by many components (theme, auth, i18n) — not for high-frequency updates
92
+ - External store (Zustand, Jotai, Redux Toolkit) when state must persist across route changes, sync across tabs, or be debugged via devtools
93
+ - Never duplicate state that can be derived — compute during render
94
+
95
+ ## Class Components
96
+
97
+ Forbidden in new code. Convert legacy class components to function components when touching them for non-trivial changes.
98
+
99
+ ## File Layout per Component
100
+
101
+ ```
102
+ components/UserCard/
103
+ UserCard.tsx
104
+ UserCard.module.css # or styled-components, or Tailwind classes inline
105
+ UserCard.test.tsx
106
+ index.ts # re-export only
107
+ ```
108
+
109
+ Inline single-file components are fine for trivial presentational pieces.