@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,329 @@
1
+ ---
2
+ name: golang-testing
3
+ description: Use when writing or improving Go tests with table-driven tests, helpers, benchmarking, race detection, coverage analysis, and integration testing patterns.
4
+ metadata:
5
+ origin: ECC
6
+ globs: ["**/*.go", "**/go.mod", "**/go.sum"]
7
+ ---
8
+
9
+ # Go Testing
10
+
11
+ > This skill provides comprehensive Go testing patterns extending common testing principles with Go-specific idioms.
12
+
13
+ ## Testing Framework
14
+
15
+ Use the standard `go test` with **table-driven tests** as the primary pattern.
16
+
17
+ ### Table-Driven Tests
18
+
19
+ The idiomatic Go testing pattern:
20
+
21
+ ```go
22
+ func TestValidateEmail(t *testing.T) {
23
+ tests := []struct {
24
+ name string
25
+ email string
26
+ wantErr bool
27
+ }{
28
+ {
29
+ name: "valid email",
30
+ email: "user@example.com",
31
+ wantErr: false,
32
+ },
33
+ {
34
+ name: "missing @",
35
+ email: "userexample.com",
36
+ wantErr: true,
37
+ },
38
+ {
39
+ name: "empty string",
40
+ email: "",
41
+ wantErr: true,
42
+ },
43
+ }
44
+
45
+ for _, tt := range tests {
46
+ t.Run(tt.name, func(t *testing.T) {
47
+ err := ValidateEmail(tt.email)
48
+ if (err != nil) != tt.wantErr {
49
+ t.Errorf("ValidateEmail(%q) error = %v, wantErr %v",
50
+ tt.email, err, tt.wantErr)
51
+ }
52
+ })
53
+ }
54
+ }
55
+ ```
56
+
57
+ **Benefits:**
58
+ - Easy to add new test cases
59
+ - Clear test case documentation
60
+ - Parallel test execution with `t.Parallel()`
61
+ - Isolated subtests with `t.Run()`
62
+
63
+ ## Test Helpers
64
+
65
+ Use `t.Helper()` to mark helper functions:
66
+
67
+ ```go
68
+ func assertNoError(t *testing.T, err error) {
69
+ t.Helper()
70
+ if err != nil {
71
+ t.Fatalf("unexpected error: %v", err)
72
+ }
73
+ }
74
+
75
+ func assertEqual(t *testing.T, got, want interface{}) {
76
+ t.Helper()
77
+ if !reflect.DeepEqual(got, want) {
78
+ t.Errorf("got %v, want %v", got, want)
79
+ }
80
+ }
81
+ ```
82
+
83
+ **Benefits:**
84
+ - Correct line numbers in test failures
85
+ - Reusable test utilities
86
+ - Cleaner test code
87
+
88
+ ## Test Fixtures
89
+
90
+ Use `t.Cleanup()` for resource cleanup:
91
+
92
+ ```go
93
+ func testDB(t *testing.T) *sql.DB {
94
+ t.Helper()
95
+
96
+ db, err := sql.Open("sqlite3", ":memory:")
97
+ if err != nil {
98
+ t.Fatalf("failed to open test db: %v", err)
99
+ }
100
+
101
+ // Cleanup runs after test completes
102
+ t.Cleanup(func() {
103
+ if err := db.Close(); err != nil {
104
+ t.Errorf("failed to close db: %v", err)
105
+ }
106
+ })
107
+
108
+ return db
109
+ }
110
+
111
+ func TestUserRepository(t *testing.T) {
112
+ db := testDB(t)
113
+ repo := NewUserRepository(db)
114
+ // ... test logic
115
+ }
116
+ ```
117
+
118
+ ## Race Detection
119
+
120
+ Always run tests with the `-race` flag to detect data races:
121
+
122
+ ```bash
123
+ go test -race ./...
124
+ ```
125
+
126
+ **In CI/CD:**
127
+ ```yaml
128
+ - name: Test with race detector
129
+ run: go test -race -timeout 5m ./...
130
+ ```
131
+
132
+ **Why:**
133
+ - Detects concurrent access bugs
134
+ - Prevents production race conditions
135
+ - Minimal performance overhead in tests
136
+
137
+ ## Coverage Analysis
138
+
139
+ ### Basic Coverage
140
+
141
+ ```bash
142
+ go test -cover ./...
143
+ ```
144
+
145
+ ### Detailed Coverage Report
146
+
147
+ ```bash
148
+ go test -coverprofile=coverage.out ./...
149
+ go tool cover -html=coverage.out
150
+ ```
151
+
152
+ ### Coverage Thresholds
153
+
154
+ ```bash
155
+ # Fail if coverage below 80%
156
+ go test -cover ./... | grep -E 'coverage: [0-7][0-9]\.[0-9]%' && exit 1
157
+ ```
158
+
159
+ ## Benchmarking
160
+
161
+ ```go
162
+ func BenchmarkValidateEmail(b *testing.B) {
163
+ email := "user@example.com"
164
+
165
+ b.ResetTimer()
166
+ for i := 0; i < b.N; i++ {
167
+ ValidateEmail(email)
168
+ }
169
+ }
170
+ ```
171
+
172
+ **Run benchmarks:**
173
+ ```bash
174
+ go test -bench=. -benchmem
175
+ ```
176
+
177
+ **Compare benchmarks:**
178
+ ```bash
179
+ go test -bench=. -benchmem > old.txt
180
+ # make changes
181
+ go test -bench=. -benchmem > new.txt
182
+ benchstat old.txt new.txt
183
+ ```
184
+
185
+ ## Mocking
186
+
187
+ ### Interface-Based Mocking
188
+
189
+ ```go
190
+ type UserRepository interface {
191
+ GetUser(id string) (*User, error)
192
+ }
193
+
194
+ type mockUserRepository struct {
195
+ users map[string]*User
196
+ err error
197
+ }
198
+
199
+ func (m *mockUserRepository) GetUser(id string) (*User, error) {
200
+ if m.err != nil {
201
+ return nil, m.err
202
+ }
203
+ return m.users[id], nil
204
+ }
205
+
206
+ func TestUserService(t *testing.T) {
207
+ mock := &mockUserRepository{
208
+ users: map[string]*User{
209
+ "1": {ID: "1", Name: "Alice"},
210
+ },
211
+ }
212
+
213
+ service := NewUserService(mock)
214
+ // ... test logic
215
+ }
216
+ ```
217
+
218
+ ## Integration Tests
219
+
220
+ ### Build Tags
221
+
222
+ ```go
223
+ //go:build integration
224
+ // +build integration
225
+
226
+ package user_test
227
+
228
+ func TestUserRepository_Integration(t *testing.T) {
229
+ // ... integration test
230
+ }
231
+ ```
232
+
233
+ **Run integration tests:**
234
+ ```bash
235
+ go test -tags=integration ./...
236
+ ```
237
+
238
+ ### Test Containers
239
+
240
+ ```go
241
+ func TestWithPostgres(t *testing.T) {
242
+ if testing.Short() {
243
+ t.Skip("skipping integration test")
244
+ }
245
+
246
+ // Setup test container
247
+ ctx := context.Background()
248
+ container, err := testcontainers.GenericContainer(ctx, ...)
249
+ assertNoError(t, err)
250
+
251
+ t.Cleanup(func() {
252
+ container.Terminate(ctx)
253
+ })
254
+
255
+ // ... test logic
256
+ }
257
+ ```
258
+
259
+ ## Test Organization
260
+
261
+ ### File Structure
262
+
263
+ ```
264
+ package/
265
+ ├── user.go
266
+ ├── user_test.go # Unit tests
267
+ ├── user_integration_test.go # Integration tests
268
+ └── testdata/ # Test fixtures
269
+ └── users.json
270
+ ```
271
+
272
+ ### Package Naming
273
+
274
+ ```go
275
+ // Black-box testing (external perspective)
276
+ package user_test
277
+
278
+ // White-box testing (internal access)
279
+ package user
280
+ ```
281
+
282
+ ## Common Patterns
283
+
284
+ ### Testing HTTP Handlers
285
+
286
+ ```go
287
+ func TestUserHandler(t *testing.T) {
288
+ req := httptest.NewRequest("GET", "/users/1", nil)
289
+ rec := httptest.NewRecorder()
290
+
291
+ handler := NewUserHandler(mockRepo)
292
+ handler.ServeHTTP(rec, req)
293
+
294
+ assertEqual(t, rec.Code, http.StatusOK)
295
+ }
296
+ ```
297
+
298
+ ### Testing with Context
299
+
300
+ ```go
301
+ func TestWithTimeout(t *testing.T) {
302
+ ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
303
+ defer cancel()
304
+
305
+ err := SlowOperation(ctx)
306
+ if !errors.Is(err, context.DeadlineExceeded) {
307
+ t.Errorf("expected timeout error, got %v", err)
308
+ }
309
+ }
310
+ ```
311
+
312
+ ## Best Practices
313
+
314
+ 1. **Use `t.Parallel()`** for independent tests
315
+ 2. **Use `testing.Short()`** to skip slow tests
316
+ 3. **Use `t.TempDir()`** for temporary directories
317
+ 4. **Use `t.Setenv()`** for environment variables
318
+ 5. **Avoid `init()`** in test files
319
+ 6. **Keep tests focused** - one behavior per test
320
+ 7. **Use meaningful test names** - describe what's being tested
321
+
322
+ ## When to Use This Skill
323
+
324
+ - Writing new Go tests
325
+ - Improving test coverage
326
+ - Setting up test infrastructure
327
+ - Debugging flaky tests
328
+ - Optimizing test performance
329
+ - Implementing integration tests
@@ -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,10 @@
1
+ # Third-party notice
2
+
3
+ This skill was copied from Affaan Mustafa's ECC repository.
4
+
5
+ - Source: https://github.com/affaan-m/ECC/tree/main/skills/java-coding-standards
6
+ - Source commit: 0f84c0e2796703fbda87d577b2636351418c7442
7
+ - License: MIT
8
+ - Copyright: Copyright (c) 2026 Affaan Mustafa
9
+
10
+ The upstream MIT license is included in `LICENSE`.