@pratikpsl/agent-skills 1.2.0 → 1.3.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.
- package/README.md +28 -2
- package/dist/core/ide-map.js +1 -1
- package/dist/core/resolve-template.d.ts.map +1 -1
- package/dist/core/resolve-template.js +1 -1
- package/dist/core/resolve-template.js.map +1 -1
- package/package.json +3 -1
- package/templates/default/instructions.md +4 -2
- package/templates/dotnet/AgentSkills/skills/index.md +14 -0
- package/templates/python/AgentSkills/agents/architect.md +13 -0
- package/templates/python/AgentSkills/agents/developer.md +23 -0
- package/templates/python/AgentSkills/skills/index.md +14 -0
- package/templates/python/AgentSkills/skills/performance/SKILL.md +26 -0
- package/templates/python/AgentSkills/skills/python-best-practices/SKILL.md +59 -0
- package/templates/python/AgentSkills/skills/python-typing/SKILL.md +42 -0
- package/templates/python/AgentSkills/skills/testing/SKILL.md +42 -0
- package/templates/react/AgentSkills/skills/index.md +13 -0
- package/templates/rust/AgentSkills/agents/architect.md +14 -0
- package/templates/rust/AgentSkills/agents/developer.md +24 -0
- package/templates/rust/AgentSkills/skills/index.md +14 -0
- package/templates/rust/AgentSkills/skills/performance/SKILL.md +43 -0
- package/templates/rust/AgentSkills/skills/rust-best-practices/SKILL.md +48 -0
- package/templates/rust/AgentSkills/skills/rust-ownership/SKILL.md +40 -0
- package/templates/rust/AgentSkills/skills/testing/SKILL.md +60 -0
- package/templates/shared/AgentSkills/OPERATING.md +2 -2
- package/templates/shared/AgentSkills/skills/index.md +10 -0
- package/templates/shared/AgentSkills/skills/standards/SKILL.md +12 -3
- package/templates/shared/entry-points/instructions.md +2 -2
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Running with an **agent name** or `shared` automatically installs shared skills
|
|
|
18
18
|
# Install shared skills + specific IDE / Agent entry point
|
|
19
19
|
npx @pratikpsl/agent-skills antigravity # → .agents/rules/GEMINI.md + AgentSkills/
|
|
20
20
|
npx @pratikpsl/agent-skills cursor # → .cursor/rules/instructions.md + AgentSkills/
|
|
21
|
-
npx @pratikpsl/agent-skills claude # →
|
|
21
|
+
npx @pratikpsl/agent-skills claude # → AGENTS.md + AgentSkills/
|
|
22
22
|
npx @pratikpsl/agent-skills code # → AGENTS.md + AgentSkills/
|
|
23
23
|
npx @pratikpsl/agent-skills codex # → AGENTS.md + AgentSkills/
|
|
24
24
|
npx @pratikpsl/agent-skills copilot # → .github/copilot-instructions.md + AgentSkills/
|
|
@@ -59,6 +59,28 @@ npx @pratikpsl/agent-skills react --agent cursor
|
|
|
59
59
|
npx @pratikpsl/agent-skills react --agent claude
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
+
### Python Template
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Install Python agent skills + all IDE entry points
|
|
66
|
+
npx @pratikpsl/agent-skills python
|
|
67
|
+
|
|
68
|
+
# Install Python agent skills + specific agent entry point only
|
|
69
|
+
npx @pratikpsl/agent-skills python --agent cursor
|
|
70
|
+
npx @pratikpsl/agent-skills python --agent claude
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Rust Template
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Install Rust agent skills + all IDE entry points
|
|
77
|
+
npx @pratikpsl/agent-skills rust
|
|
78
|
+
|
|
79
|
+
# Install Rust agent skills + specific agent entry point only
|
|
80
|
+
npx @pratikpsl/agent-skills rust --agent cursor
|
|
81
|
+
npx @pratikpsl/agent-skills rust --agent claude
|
|
82
|
+
```
|
|
83
|
+
|
|
62
84
|
*(You can also use `bunx @pratikpsl/agent-skills` in Bun environments).*
|
|
63
85
|
|
|
64
86
|
---
|
|
@@ -69,7 +91,7 @@ npx @pratikpsl/agent-skills react --agent claude
|
|
|
69
91
|
Usage: agent-skills [options] [template]
|
|
70
92
|
|
|
71
93
|
Arguments:
|
|
72
|
-
template Template: default, dotnet, react, shared; agent names install shared guidance
|
|
94
|
+
template Template: default, dotnet, python, react, rust, shared; agent names install shared guidance
|
|
73
95
|
|
|
74
96
|
Options:
|
|
75
97
|
-V, --version output the version number
|
|
@@ -89,7 +111,9 @@ Options:
|
|
|
89
111
|
| --- | --- | --- |
|
|
90
112
|
| `shared` | `templates/shared/` | Base operating contract, core skills (principles, standards, security, review), review & architecture agents (`architect.md`, `reviewer.md`) |
|
|
91
113
|
| `dotnet` | `templates/dotnet/` | .NET/C# skills, architecture & developer agents (`architect.md`, `developer.md`), memory |
|
|
114
|
+
| `python` | `templates/python/` | Python skills (PEP 8, uv, typing, testing, performance), architecture & developer agents (`architect.md`, `developer.md`) |
|
|
92
115
|
| `react` | `templates/react/` | React & TypeScript skills, frontend testing, developer agent (`developer.md`) |
|
|
116
|
+
| `rust` | `templates/rust/` | Rust skills (ownership, best-practices, testing, performance), architecture & developer agents (`architect.md`, `developer.md`) |
|
|
93
117
|
| `default` | `templates/default/` | Compact single-file agent instructions without AgentSkills folder |
|
|
94
118
|
|
|
95
119
|
---
|
|
@@ -108,7 +132,9 @@ coding-skills-ai/
|
|
|
108
132
|
├── templates/
|
|
109
133
|
│ ├── default/ # Single-file instructions
|
|
110
134
|
│ ├── dotnet/ # .NET template
|
|
135
|
+
│ ├── python/ # Python template
|
|
111
136
|
│ ├── react/ # React template
|
|
137
|
+
│ ├── rust/ # Rust template
|
|
112
138
|
│ └── shared/ # Shared operating contract & memory
|
|
113
139
|
├── tests/ # Vitest test suite
|
|
114
140
|
├── bun.lock # Reproducible lockfile
|
package/dist/core/ide-map.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-template.d.ts","sourceRoot":"","sources":["../../src/core/resolve-template.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"resolve-template.d.ts","sourceRoot":"","sources":["../../src/core/resolve-template.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,UAA6D,CAAC;AAMzF,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWpD"}
|
|
@@ -2,7 +2,7 @@ import { existsSync } from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { fileURLToPath } from "url";
|
|
4
4
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
|
-
export const TEMPLATE_NAMES = ["default", "dotnet", "react", "shared"];
|
|
5
|
+
export const TEMPLATE_NAMES = ["default", "dotnet", "python", "react", "rust", "shared"];
|
|
6
6
|
function templatesRoot() {
|
|
7
7
|
return path.resolve(__dirname, "..", "..", "templates");
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-template.js","sourceRoot":"","sources":["../../src/core/resolve-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve-template.js","sourceRoot":"","sources":["../../src/core/resolve-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEzF,SAAS,aAAa;IACpB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,QAAQ,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,cAAc,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvF,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,CAAC,CAAC;IACrD,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,qCAAqC,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pratikpsl/agent-skills",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"description": "CLI to scaffold and manage AI agent skills across projects — like shadcn/ui, but for Cursor, Claude, Codex, Copilot, Antigravity, and more",
|
|
6
6
|
"bin": {
|
|
7
7
|
"agent-skills": "dist/bin/agent-skills.js"
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
"copilot",
|
|
27
27
|
"codex",
|
|
28
28
|
"dotnet",
|
|
29
|
+
"python",
|
|
30
|
+
"rust",
|
|
29
31
|
"agents",
|
|
30
32
|
"antigravity",
|
|
31
33
|
"typescript"
|
|
@@ -18,7 +18,8 @@ minimizing the diff, following the project's own architecture and conventions.
|
|
|
18
18
|
- Keep functions under 50 lines, nesting depth at most 2 levels (prefer early returns), and signatures under 4 parameters.
|
|
19
19
|
- Use meaningful names and named constants/enums (no magic numbers or strings).
|
|
20
20
|
- Design self-describing APIs, structured schemas, and human-/machine-readable contracts.
|
|
21
|
-
- Comment only where non-obvious rationale is required, not what the code already says.
|
|
21
|
+
- Comment only where non-obvious rationale is required, not what the code already says. Comments should explain "why" not "what". CODE SHOULD BE SELF-DESCRIBING.
|
|
22
|
+
|
|
22
23
|
|
|
23
24
|
### Reliability & Security
|
|
24
25
|
- Never hardcode, commit, or log secrets, credentials, tokens, or sensitive user data.
|
|
@@ -30,9 +31,10 @@ minimizing the diff, following the project's own architecture and conventions.
|
|
|
30
31
|
- Review code against five core dimensions: correctness (boundaries, errors, race conditions), readability (depth <= 2, functions <= 50 lines), architecture (SOLID, KISS), security, and performance.
|
|
31
32
|
- Review tests first; address root causes over symptoms (fix shared logic once).
|
|
32
33
|
- Categorize findings clearly (Critical, Important, Suggestion) and provide concrete, actionable fixes.
|
|
34
|
+
- Maximum 2 levels of nesting; prefer early returns to flatten control flow.
|
|
33
35
|
|
|
34
36
|
## Definition of Done
|
|
35
|
-
- Builds cleanly
|
|
37
|
+
- Builds cleanly without any errors.
|
|
36
38
|
- No debug code, dead code, unused imports, or temporary files left behind.
|
|
37
39
|
- Changes are minimal, focused, covered by tests, and easy to review.
|
|
38
40
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Skills Index
|
|
2
|
+
|
|
3
|
+
Consult this index to load only the skills relevant to the current task.
|
|
4
|
+
|
|
5
|
+
| Skill | Path | Description / When to Load |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| principles | AgentSkills/skills/principles/SKILL.md | Foundational simplicity ladder, KISS, YAGNI, surgical changes |
|
|
8
|
+
| standards | AgentSkills/skills/standards/SKILL.md | Code quality, 50-line limits, shallow nesting, clean signatures |
|
|
9
|
+
| security | AgentSkills/skills/security/SKILL.md | Input validation, secrets handling, safe queries, least privilege |
|
|
10
|
+
| review | AgentSkills/skills/review/SKILL.md | Code review framework, five review dimensions, verification rules |
|
|
11
|
+
| dotnet-best-practices | AgentSkills/skills/dotnet-best-practices/SKILL.md | C# idioms, CQRS, EF Core, DI lifetimes, async/await, logging |
|
|
12
|
+
| dotnet-api | AgentSkills/skills/dotnet-api/SKILL.md | RESTful API design, HTTP methods, pagination, OpenAPI/Swagger |
|
|
13
|
+
| csharp-xunit | AgentSkills/skills/csharp-xunit/SKILL.md | xUnit testing, AAA pattern, Facts vs Theories, mocking, assertions |
|
|
14
|
+
| performance | AgentSkills/skills/performance/SKILL.md | Span/ReadOnlySpan, ValueTask, EF Core query tuning, memory pooling |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architect
|
|
3
|
+
description: Python architectural design, Clean Architecture, module boundaries, and pyproject.toml packaging.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Python Architect
|
|
7
|
+
|
|
8
|
+
## Architectural Principles
|
|
9
|
+
- **Layered Separation**: Enforce clean boundaries across `domain` (entities, value objects), `application` (use cases, services), `infrastructure` (DB, HTTP, queue adapters), and `api` (FastAPI/Flask routes or CLI entry points).
|
|
10
|
+
- **Dependency Direction**: Outer layers depend on inner layers; never let `domain` import from `infrastructure`.
|
|
11
|
+
- **Contract-First Design**: Define `pydantic` schemas and typed interfaces before implementation. Treat data shapes as the primary design artifact.
|
|
12
|
+
- **Packaging**: Structure projects with `pyproject.toml` (`[project]`, `[build-system]`, `[tool.mypy]`, `[tool.ruff]`). Use namespace packages only when cross-team sharing genuinely requires it.
|
|
13
|
+
- **Genuine Reusability**: Extract shared utilities only when the same logic is needed across at least two distinct domains. Avoid premature abstraction (YAGNI).
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: developer
|
|
3
|
+
description: Python feature implementation, async I/O, strict static typing, and uv project management.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Python Developer
|
|
7
|
+
|
|
8
|
+
## Implementation Principles
|
|
9
|
+
- **PEP Naming**: `snake_case` for functions, variables, and modules; `PascalCase` for classes; `UPPER_SNAKE_CASE` for constants; `_prefixed` for private members.
|
|
10
|
+
- **Static Typing**: Annotate every function signature and class attribute. Enable `from __future__ import annotations` at the top of every module.
|
|
11
|
+
- **Pydantic Models**: Use `pydantic.BaseModel` for all data contracts, API request/response bodies, and configuration objects. Never use untyped dicts as data boundaries.
|
|
12
|
+
- **Complexity Limits**: Keep functions under 50 lines; maximum 2 levels of nesting; prefer early returns to flatten control flow.
|
|
13
|
+
- **No Magic Literals**: Replace all magic numbers and strings with named constants or `enum.Enum` members.
|
|
14
|
+
|
|
15
|
+
## Project & Dependency Management
|
|
16
|
+
- Use `uv` for all project operations: `uv init`, `uv add`, `uv run`, `uv sync`.
|
|
17
|
+
- Declare all dependencies in `pyproject.toml`; never mutate the global environment with bare `pip install`.
|
|
18
|
+
- Pin direct dependencies; let `uv.lock` track the full resolved set.
|
|
19
|
+
|
|
20
|
+
## Async & I/O
|
|
21
|
+
- Use `async`/`await` for all I/O, network, and database operations.
|
|
22
|
+
- Propagate cancellation via `asyncio.CancelledError`; never swallow it silently.
|
|
23
|
+
- Use `asyncio.gather` or task groups (`asyncio.TaskGroup`) for concurrent work; avoid blocking calls on the event loop.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Skills Index
|
|
2
|
+
|
|
3
|
+
Consult this index to load only the skills relevant to the current task.
|
|
4
|
+
|
|
5
|
+
| Skill | Path | Description / When to Load |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| principles | AgentSkills/skills/principles/SKILL.md | Foundational simplicity ladder, KISS, YAGNI, surgical changes |
|
|
8
|
+
| standards | AgentSkills/skills/standards/SKILL.md | Code quality, 50-line limits, shallow nesting, clean signatures |
|
|
9
|
+
| security | AgentSkills/skills/security/SKILL.md | Input validation, secrets handling, safe queries, least privilege |
|
|
10
|
+
| review | AgentSkills/skills/review/SKILL.md | Code review framework, five review dimensions, verification rules |
|
|
11
|
+
| python-best-practices | AgentSkills/skills/python-best-practices/SKILL.md | PEP 8 conventions, uv project setup, ruff, async patterns, logging |
|
|
12
|
+
| python-typing | AgentSkills/skills/python-typing/SKILL.md | Strict static typing, mypy/pyright, pydantic models, Protocol, TypeVar |
|
|
13
|
+
| testing | AgentSkills/skills/testing/SKILL.md | pytest, pytest-asyncio, hypothesis property testing, fixtures, mocks |
|
|
14
|
+
| performance | AgentSkills/skills/performance/SKILL.md | cProfile/memray, generators, asyncio concurrency, connection pooling |
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: performance
|
|
3
|
+
description: Python profiling, generator patterns, async concurrency, and memory optimization.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Python Performance
|
|
7
|
+
|
|
8
|
+
## Profiling First
|
|
9
|
+
- Measure before optimizing: use `cProfile`/`profile` for CPU and `memray` or `tracemalloc` for memory.
|
|
10
|
+
- Profile realistic workloads, not microbenchmarks, to find true hot paths.
|
|
11
|
+
|
|
12
|
+
## Memory Efficiency
|
|
13
|
+
- Prefer generators and iterators (`yield`) over materializing full lists in memory for large data sets.
|
|
14
|
+
- Use `__slots__` on classes with many instances to eliminate per-instance `__dict__` overhead.
|
|
15
|
+
- Use `functools.lru_cache` or `functools.cache` for pure, referentially transparent functions called repeatedly with the same arguments.
|
|
16
|
+
|
|
17
|
+
## Async Concurrency
|
|
18
|
+
- Use `asyncio.gather(*tasks)` or `asyncio.TaskGroup` for I/O-bound fan-out; avoid sequential `await` in a loop when tasks are independent.
|
|
19
|
+
- Use connection pools (e.g. `asyncpg` pool, `httpx.AsyncClient`) — never create a new connection per request.
|
|
20
|
+
- Offload CPU-bound work to a `ProcessPoolExecutor` via `loop.run_in_executor`; do not block the event loop.
|
|
21
|
+
|
|
22
|
+
## Data & Algorithm Choices
|
|
23
|
+
- Use built-in types (`list`, `dict`, `set`) over third-party equivalents for simple cases; they are implemented in C.
|
|
24
|
+
- Use `collections.deque` for queue workloads; avoid `list.pop(0)` (O(n)).
|
|
25
|
+
- Avoid repeated string concatenation in loops; use `"".join(parts)` instead.
|
|
26
|
+
- Prefer comprehensions over `map`/`filter` with lambdas for readability and slight speed advantages.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: python-best-practices
|
|
3
|
+
description: >
|
|
4
|
+
Load when writing, reviewing, refactoring, or optimizing Python code.
|
|
5
|
+
Covers PEP conventions, uv project management, async patterns, error handling,
|
|
6
|
+
structured logging, and maintainability.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Python Best Practices
|
|
10
|
+
|
|
11
|
+
## Naming Conventions (PEP 8)
|
|
12
|
+
- **Modules & packages**: `snake_case` (`user_service.py`, `auth/`)
|
|
13
|
+
- **Functions & variables**: `snake_case` (`get_user`, `is_valid`)
|
|
14
|
+
- **Classes**: `PascalCase` (`UserService`, `OrderRepository`)
|
|
15
|
+
- **Constants**: `UPPER_SNAKE_CASE` (`MAX_RETRIES`, `DEFAULT_TIMEOUT`)
|
|
16
|
+
- **Private members**: single underscore prefix (`_internal_helper`)
|
|
17
|
+
- **Dunder methods**: reserved for Python protocols (`__init__`, `__repr__`)
|
|
18
|
+
|
|
19
|
+
## Project Setup with uv
|
|
20
|
+
```bash
|
|
21
|
+
uv init my-project # scaffold pyproject.toml, src layout
|
|
22
|
+
uv add fastapi pydantic # add runtime dependencies
|
|
23
|
+
uv add --dev pytest mypy ruff # add dev dependencies
|
|
24
|
+
uv sync # install from uv.lock
|
|
25
|
+
uv run pytest # run commands in the managed venv
|
|
26
|
+
```
|
|
27
|
+
- Always use `uv`; never run bare `pip install` against the global environment.
|
|
28
|
+
- Declare all metadata in `pyproject.toml` (`[project]`, `[build-system]`, tool configs).
|
|
29
|
+
|
|
30
|
+
## Code Quality & Formatting
|
|
31
|
+
- Use `ruff` for linting and formatting (replaces `flake8`, `isort`, `black`).
|
|
32
|
+
- Enable `ruff` rules `E`, `F`, `I`, `UP`, `ANN` at minimum in `pyproject.toml`.
|
|
33
|
+
- Run `mypy --strict` in CI; no type errors are acceptable in production code.
|
|
34
|
+
|
|
35
|
+
## Async & I/O
|
|
36
|
+
- Use `async`/`await` for all I/O-bound operations (HTTP, database, file, queue).
|
|
37
|
+
- Never call blocking functions (`time.sleep`, `open()`, sync DB calls) inside an async context; use their async equivalents.
|
|
38
|
+
- Use `asyncio.TaskGroup` (Python 3.11+) for structured concurrent tasks.
|
|
39
|
+
- Propagate `asyncio.CancelledError`; never catch it without re-raising.
|
|
40
|
+
|
|
41
|
+
## Error Handling
|
|
42
|
+
- Define domain-specific exception classes inheriting from a project base (`AppError`).
|
|
43
|
+
- Catch the narrowest exception type possible; never use bare `except:` or `except Exception:` without logging and re-raising.
|
|
44
|
+
- Use `contextlib.suppress` only for explicitly expected, recoverable errors.
|
|
45
|
+
|
|
46
|
+
## Logging
|
|
47
|
+
- Use structured logging (`structlog` or `logging` with a JSON formatter) — never `print()` in production code.
|
|
48
|
+
- Bind contextual fields (request IDs, user IDs) to the logger at request scope.
|
|
49
|
+
- Never log secrets, tokens, passwords, or PII.
|
|
50
|
+
|
|
51
|
+
## Review Checklist
|
|
52
|
+
- [ ] All names follow PEP 8 conventions.
|
|
53
|
+
- [ ] `uv` used for dependency management; `pyproject.toml` up to date.
|
|
54
|
+
- [ ] No bare `pip install` or unpinned dependencies.
|
|
55
|
+
- [ ] `ruff` passes with zero errors.
|
|
56
|
+
- [ ] `mypy --strict` passes with zero errors.
|
|
57
|
+
- [ ] No blocking calls inside `async` functions.
|
|
58
|
+
- [ ] Structured logging used; no `print()` statements remain.
|
|
59
|
+
- [ ] Narrow exception handling; no silent swallowing of errors.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: python-typing
|
|
3
|
+
description: >
|
|
4
|
+
Load when writing or reviewing Python code. Covers strict static typing with mypy/pyright,
|
|
5
|
+
pydantic data models, Protocol, TypeVar, Literal, and TypedDict patterns.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Python Static Typing
|
|
9
|
+
|
|
10
|
+
## Module Setup
|
|
11
|
+
- Add `from __future__ import annotations` as the first import in every module to enable postponed evaluation of annotations (PEP 563).
|
|
12
|
+
- Enable strict mode in `pyproject.toml`:
|
|
13
|
+
```toml
|
|
14
|
+
[tool.mypy]
|
|
15
|
+
strict = true
|
|
16
|
+
warn_return_any = true
|
|
17
|
+
disallow_untyped_defs = true
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Function & Variable Annotations
|
|
21
|
+
- Annotate every function parameter, return type, and class attribute without exception.
|
|
22
|
+
- Use `None` as an explicit return type for functions that return nothing; never omit the annotation.
|
|
23
|
+
- Avoid `Any` — use `object` for truly unknown types, or narrow with generics and `TypeVar`.
|
|
24
|
+
|
|
25
|
+
## Type Constructs
|
|
26
|
+
- **`TypeAlias`**: Use `type Alias = ...` (Python 3.12+) or `TypeAlias` from `typing` for readable compound types.
|
|
27
|
+
- **`Protocol`**: Prefer structural subtyping (`Protocol`) over ABCs for dependency injection and testability.
|
|
28
|
+
- **`TypeVar` / `ParamSpec`**: Use for generic functions and decorators; constrain with `bound=` where applicable.
|
|
29
|
+
- **`Literal`**: Use `Literal["value"]` to narrow string/int constants in type signatures.
|
|
30
|
+
- **`TypedDict`**: Use for dict shapes at external boundaries (JSON, config); prefer `pydantic.BaseModel` for mutable internal models.
|
|
31
|
+
|
|
32
|
+
## Pydantic Models
|
|
33
|
+
- Define all data contracts as `pydantic.BaseModel` subclasses; never pass raw `dict` across layer boundaries.
|
|
34
|
+
- Use `model_config = ConfigDict(frozen=True)` for immutable value objects.
|
|
35
|
+
- Validate external inputs at the outermost boundary (API, CLI, queue consumer) before passing into application logic.
|
|
36
|
+
|
|
37
|
+
## Review Checklist
|
|
38
|
+
- [ ] `from __future__ import annotations` present in every module.
|
|
39
|
+
- [ ] No `Any` without a documented justification comment.
|
|
40
|
+
- [ ] All function signatures fully annotated (parameters + return).
|
|
41
|
+
- [ ] Pydantic models used at all data boundaries.
|
|
42
|
+
- [ ] `mypy --strict` passes with zero errors.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testing
|
|
3
|
+
description: Python unit, async, and property-based testing with pytest, pytest-asyncio, and hypothesis.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Python Testing
|
|
7
|
+
|
|
8
|
+
## Testing Principles
|
|
9
|
+
- Test observable behavior and public interfaces, not internal implementation details.
|
|
10
|
+
- Follow the **Arrange-Act-Assert (AAA)** pattern in every test.
|
|
11
|
+
- Keep tests isolated, deterministic, and independent of execution order or external state.
|
|
12
|
+
|
|
13
|
+
## Project Setup
|
|
14
|
+
- Use `pytest` as the sole test runner; install via `uv add --dev pytest pytest-asyncio pytest-mock hypothesis`.
|
|
15
|
+
- Configure in `pyproject.toml`:
|
|
16
|
+
```toml
|
|
17
|
+
[tool.pytest.ini_options]
|
|
18
|
+
asyncio_mode = "auto"
|
|
19
|
+
```
|
|
20
|
+
- Run tests with `uv run pytest`.
|
|
21
|
+
|
|
22
|
+
## Test Naming & Structure
|
|
23
|
+
- Name test files `test_<module>.py` and place them under a top-level `tests/` directory mirroring the `src/` layout.
|
|
24
|
+
- Name test functions: `test_<function>_<scenario>_<expected>` (e.g., `test_create_user_duplicate_email_raises_conflict`).
|
|
25
|
+
- Match test class names to the class under test: `TestUserService` for `UserService`.
|
|
26
|
+
|
|
27
|
+
## Fixtures & Parametrize
|
|
28
|
+
- Use `@pytest.fixture` for shared setup; prefer function-scoped fixtures unless sharing is explicitly required.
|
|
29
|
+
- Use `@pytest.mark.parametrize` for data-driven cases covering multiple inputs and edge cases.
|
|
30
|
+
- Mock external I/O boundaries (HTTP, DB, file system) using `pytest-mock` (`mocker.patch`) — never hit real services in unit tests.
|
|
31
|
+
|
|
32
|
+
## Async Testing
|
|
33
|
+
- Annotate async test functions with `async def`; `asyncio_mode = "auto"` removes the need for `@pytest.mark.asyncio`.
|
|
34
|
+
- Use `AsyncMock` from `unittest.mock` to mock async callables and coroutines.
|
|
35
|
+
|
|
36
|
+
## Property-Based Testing
|
|
37
|
+
- Use `hypothesis` for algorithmic and data-parsing logic where exhaustive edge-case enumeration is impractical.
|
|
38
|
+
- Define `@given(st.text(), st.integers())` strategies; always run with a fixed `settings(max_examples=200)` in CI.
|
|
39
|
+
|
|
40
|
+
## Coverage & Quality
|
|
41
|
+
- Target 100% coverage on domain and application layers; exclude infrastructure adapters only with justification.
|
|
42
|
+
- Run `uv run pytest --cov=src --cov-report=term-missing` in CI.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Skills Index
|
|
2
|
+
|
|
3
|
+
Consult this index to load only the skills relevant to the current task.
|
|
4
|
+
|
|
5
|
+
| Skill | Path | Description / When to Load |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| principles | AgentSkills/skills/principles/SKILL.md | Foundational simplicity ladder, KISS, YAGNI, surgical changes |
|
|
8
|
+
| standards | AgentSkills/skills/standards/SKILL.md | Code quality, 50-line limits, shallow nesting, clean signatures |
|
|
9
|
+
| security | AgentSkills/skills/security/SKILL.md | Input validation, secrets handling, safe queries, least privilege |
|
|
10
|
+
| review | AgentSkills/skills/review/SKILL.md | Code review framework, five review dimensions, verification rules |
|
|
11
|
+
| react-typescript | AgentSkills/skills/react-typescript/SKILL.md | React & TypeScript props typing, custom hooks, discriminated unions |
|
|
12
|
+
| testing | AgentSkills/skills/testing/SKILL.md | Vitest & React Testing Library, user-event, test coverage |
|
|
13
|
+
| performance | AgentSkills/skills/performance/SKILL.md | Render optimization, lazy loading, state colocation, memoization |
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architect
|
|
3
|
+
description: Rust workspace design, crate boundaries, trait-based API design, and visibility rules.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Rust Architect
|
|
7
|
+
|
|
8
|
+
## Architectural Principles
|
|
9
|
+
- **Workspace Layout**: Use a Cargo workspace (`[workspace]` in root `Cargo.toml`) to separate concerns: e.g. `crates/domain`, `crates/api`, `crates/infra`, `crates/cli`. Each crate has one responsibility.
|
|
10
|
+
- **Visibility Minimization**: Default to `pub(crate)` for intra-workspace sharing; expose items as `pub` only when they form the deliberate public API of the crate.
|
|
11
|
+
- **Trait-Based Design**: Define behavior through traits; depend on trait abstractions (not concrete types) at crate boundaries to enable testing and future substitution without coupling.
|
|
12
|
+
- **Contract-First**: Define data types (`struct`, `enum`) and trait interfaces before implementing business logic. Types are the primary design artifact.
|
|
13
|
+
- **Dependency Direction**: Application crates depend on domain crates; infrastructure crates depend on application traits; no domain crate imports from infrastructure.
|
|
14
|
+
- **Genuine Reusability**: Extract shared code into a library crate only when two or more crates genuinely share the same logic. Avoid premature abstraction (YAGNI).
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: developer
|
|
3
|
+
description: Rust feature implementation, ownership, async with tokio, and idiomatic error propagation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Rust Developer
|
|
7
|
+
|
|
8
|
+
## Implementation Principles
|
|
9
|
+
- **Ownership First**: Design types and function signatures to express ownership intent clearly. Prefer borrowing (`&T`, `&mut T`) over cloning in hot paths; clone only when ownership transfer is genuinely required.
|
|
10
|
+
- **Idiomatic Error Handling**: Use `Result<T, E>` and propagate errors with `?`. Never `unwrap()` or `expect()` in production code paths — reserve them for tests and infallible cases with a comment explaining why.
|
|
11
|
+
- **Zero-Cost Abstractions**: Prefer traits over dynamic dispatch (`Box<dyn Trait>`) unless runtime polymorphism is a firm requirement. Use generics for static dispatch.
|
|
12
|
+
- **Complexity Limits**: Keep functions under 50 lines; maximum 2 levels of nesting; use early `return` or `?` to flatten control flow.
|
|
13
|
+
- **No Magic Literals**: Replace all magic numbers and strings with named constants (`const`) or `enum` variants.
|
|
14
|
+
|
|
15
|
+
## Tooling Discipline
|
|
16
|
+
- Format every file with `rustfmt` before committing (`cargo fmt`).
|
|
17
|
+
- Fix all `clippy` warnings before committing (`cargo clippy -- -D warnings`).
|
|
18
|
+
- Use `cargo check` as the fast feedback loop during development.
|
|
19
|
+
|
|
20
|
+
## Async & Concurrency
|
|
21
|
+
- Use `tokio` as the async runtime for all I/O-bound work.
|
|
22
|
+
- Annotate async entry points and test functions with `#[tokio::main]` and `#[tokio::test]`.
|
|
23
|
+
- Use `tokio::spawn` for independent concurrent tasks; use `tokio::join!` or `tokio::try_join!` to await multiple tasks.
|
|
24
|
+
- Protect shared mutable state with `Arc<Mutex<T>>` or `Arc<RwLock<T>>`; prefer message-passing (`tokio::sync::mpsc`) over shared state where possible.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Skills Index
|
|
2
|
+
|
|
3
|
+
Consult this index to load only the skills relevant to the current task.
|
|
4
|
+
|
|
5
|
+
| Skill | Path | Description / When to Load |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| principles | AgentSkills/skills/principles/SKILL.md | Foundational simplicity ladder, KISS, YAGNI, surgical changes |
|
|
8
|
+
| standards | AgentSkills/skills/standards/SKILL.md | Code quality, 50-line limits, shallow nesting, clean signatures |
|
|
9
|
+
| security | AgentSkills/skills/security/SKILL.md | Input validation, secrets handling, safe queries, least privilege |
|
|
10
|
+
| review | AgentSkills/skills/review/SKILL.md | Code review framework, five review dimensions, verification rules |
|
|
11
|
+
| rust-best-practices | AgentSkills/skills/rust-best-practices/SKILL.md | API guidelines, cargo clippy/fmt, thiserror/anyhow, tracing logging |
|
|
12
|
+
| rust-ownership | AgentSkills/skills/rust-ownership/SKILL.md | Ownership, borrowing, lifetimes, Arc/Mutex, Send+Sync safety |
|
|
13
|
+
| testing | AgentSkills/skills/testing/SKILL.md | cargo test, tokio::test, proptest property testing, mockall |
|
|
14
|
+
| performance | AgentSkills/skills/performance/SKILL.md | criterion benchmarking, zero-copy parsing, allocation reduction |
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: performance
|
|
3
|
+
description: Rust benchmarking with criterion, zero-copy design, allocation reduction, and async task efficiency.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Rust Performance
|
|
7
|
+
|
|
8
|
+
## Measure First
|
|
9
|
+
- Profile before optimizing: use `criterion` for micro-benchmarks and `cargo flamegraph` (or `perf`) for real workload profiling.
|
|
10
|
+
- Compile with `--release` for all performance measurements; debug builds have no optimizations.
|
|
11
|
+
|
|
12
|
+
## Allocation & Copy Reduction
|
|
13
|
+
- Prefer borrowing (`&str`, `&[T]`) over owned types (`String`, `Vec<T>`) in hot paths; clone only when ownership transfer is necessary.
|
|
14
|
+
- Use `Cow<'_, str>` to defer allocation until a mutation is actually needed.
|
|
15
|
+
- Use `SmallVec` or fixed-size arrays for collections that are almost always small.
|
|
16
|
+
- Avoid boxing (`Box<T>`) in hot paths; prefer stack allocation for small, fixed-size types.
|
|
17
|
+
|
|
18
|
+
## Zero-Copy Parsing
|
|
19
|
+
- Use `bytes::Bytes` and slicing for zero-copy network data parsing.
|
|
20
|
+
- Avoid intermediate `String` allocations when parsing structured data; work with `&[u8]` slices directly where possible.
|
|
21
|
+
|
|
22
|
+
## Async Task Efficiency
|
|
23
|
+
- Minimize the number of `tokio::spawn` calls; spawning is cheap but not free — batch work where possible.
|
|
24
|
+
- Avoid holding `Mutex` guards across `.await` points; release before yielding.
|
|
25
|
+
- Use `tokio::sync::watch` or `tokio::sync::broadcast` for fan-out notifications instead of multiple `Mutex`-protected `Vec` callbacks.
|
|
26
|
+
|
|
27
|
+
## Iterator Pipelines
|
|
28
|
+
- Use lazy iterator adapters (`map`, `filter`, `flat_map`) over imperative loops; the compiler optimizes chains to a single pass.
|
|
29
|
+
- Prefer `collect::<Vec<_>>()` once at the end of a pipeline rather than intermediate materialization.
|
|
30
|
+
- Use `par_iter()` from `rayon` for CPU-bound parallel data processing — only after profiling confirms a bottleneck.
|
|
31
|
+
|
|
32
|
+
## Benchmarking
|
|
33
|
+
```rust
|
|
34
|
+
use criterion::{criterion_group, criterion_main, Criterion};
|
|
35
|
+
|
|
36
|
+
fn bench_parse(c: &mut Criterion) {
|
|
37
|
+
c.bench_function("parse_record", |b| b.iter(|| parse(INPUT)));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
criterion_group!(benches, bench_parse);
|
|
41
|
+
criterion_main!(benches);
|
|
42
|
+
```
|
|
43
|
+
Run with `cargo bench`.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rust-best-practices
|
|
3
|
+
description: >
|
|
4
|
+
Load when writing, reviewing, refactoring, or optimizing Rust code.
|
|
5
|
+
Covers naming conventions, clippy/rustfmt enforcement, error handling with
|
|
6
|
+
thiserror/anyhow, structured logging with tracing, and Cargo workspace layout.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Rust Best Practices
|
|
10
|
+
|
|
11
|
+
## Naming Conventions (Rust API Guidelines)
|
|
12
|
+
- **Types & Traits**: `PascalCase` (`UserRepository`, `Deserialize`)
|
|
13
|
+
- **Functions, methods, variables, modules**: `snake_case` (`get_user`, `user_service`)
|
|
14
|
+
- **Constants & statics**: `UPPER_SNAKE_CASE` (`MAX_CONNECTIONS`, `DEFAULT_TIMEOUT`)
|
|
15
|
+
- **Lifetime parameters**: short lowercase single letters (`'a`, `'db`)
|
|
16
|
+
- **Crates**: `snake_case` for library crates, `kebab-case` in `Cargo.toml` names
|
|
17
|
+
|
|
18
|
+
## Tooling Discipline
|
|
19
|
+
- **Format**: `cargo fmt` — enforce in CI with `cargo fmt --check`.
|
|
20
|
+
- **Lint**: `cargo clippy -- -D warnings` — all warnings are errors in CI; suppress individually only with a comment explaining the justification.
|
|
21
|
+
- **Audit**: `cargo audit` — run in CI to catch known vulnerabilities in dependencies.
|
|
22
|
+
- **Build**: `cargo check` for fast feedback; `cargo build --release` for benchmarks and deployment.
|
|
23
|
+
|
|
24
|
+
## Error Handling
|
|
25
|
+
- Use `thiserror` to define typed, domain-specific errors for library crates.
|
|
26
|
+
- Use `anyhow` for application-level error aggregation and context chaining (`context()`, `with_context()`).
|
|
27
|
+
- Never use `unwrap()` or `expect()` in production paths; propagate with `?`.
|
|
28
|
+
- Return `Result<T, E>` from all fallible functions; reserve `panic!` for truly unrecoverable programmer errors.
|
|
29
|
+
|
|
30
|
+
## Logging & Observability
|
|
31
|
+
- Use `tracing` for structured, async-aware logging: `tracing::info!`, `tracing::error!`, `tracing::instrument`.
|
|
32
|
+
- Attach contextual fields with `#[tracing::instrument(fields(user_id = %id))]`.
|
|
33
|
+
- Initialize the subscriber once at the application entry point (`tracing_subscriber::fmt::init()`).
|
|
34
|
+
- Never log secrets, tokens, passwords, or sensitive personal data.
|
|
35
|
+
|
|
36
|
+
## Dependency Management
|
|
37
|
+
- Minimize external dependencies; evaluate the maintenance status and license before adding a new crate.
|
|
38
|
+
- Add dev-only dependencies under `[dev-dependencies]` in `Cargo.toml`.
|
|
39
|
+
- Use feature flags to keep the dependency graph lean (`default-features = false`).
|
|
40
|
+
|
|
41
|
+
## Review Checklist
|
|
42
|
+
- [ ] `cargo fmt --check` passes.
|
|
43
|
+
- [ ] `cargo clippy -- -D warnings` passes with zero warnings.
|
|
44
|
+
- [ ] No `unwrap()` / `expect()` in non-test production code.
|
|
45
|
+
- [ ] `thiserror` used for library errors; `anyhow` for application errors.
|
|
46
|
+
- [ ] Structured `tracing` logging used; no `println!` in production.
|
|
47
|
+
- [ ] `cargo audit` passes; no known vulnerabilities.
|
|
48
|
+
- [ ] All public API items documented with `///` doc comments.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rust-ownership
|
|
3
|
+
description: >
|
|
4
|
+
Load when writing or reviewing Rust code. Covers ownership, borrowing, lifetimes,
|
|
5
|
+
shared-state concurrency with Arc/Mutex, and Send + Sync safety.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Rust Ownership & Borrowing
|
|
9
|
+
|
|
10
|
+
## Core Rules
|
|
11
|
+
- A value has exactly one owner at a time; ownership transfers on move.
|
|
12
|
+
- Borrow immutably (`&T`) as many times as needed, or mutably (`&mut T`) exactly once — never both simultaneously.
|
|
13
|
+
- References must never outlive the value they point to; the compiler enforces this via lifetimes.
|
|
14
|
+
|
|
15
|
+
## Lifetime Annotations
|
|
16
|
+
- Add explicit lifetime annotations (`'a`) only when the compiler cannot infer them — let elision work first.
|
|
17
|
+
- For structs that hold references, annotate struct lifetime parameters and bound them on the relevant fields.
|
|
18
|
+
- Prefer owned types (`String`, `Vec<T>`) over references in public APIs to avoid lifetime propagation into callers.
|
|
19
|
+
|
|
20
|
+
## Shared State
|
|
21
|
+
- Use `Arc<Mutex<T>>` for shared mutable state across threads; use `Arc<RwLock<T>>` when reads dominate.
|
|
22
|
+
- Lock mutexes for the shortest scope possible; never hold a lock across an `.await` point.
|
|
23
|
+
- Prefer message-passing (`tokio::sync::mpsc`, `std::sync::mpsc`) over shared state when tasks are naturally producer/consumer.
|
|
24
|
+
|
|
25
|
+
## Send & Sync
|
|
26
|
+
- Ensure types shared across thread boundaries implement `Send + Sync`; the compiler enforces this.
|
|
27
|
+
- Avoid `Rc<T>` and `Cell<T>` in async or multi-threaded contexts; use `Arc` and `Mutex` instead.
|
|
28
|
+
- Use `#[derive(Clone)]` sparingly on types that are expensive to clone; document where clones occur.
|
|
29
|
+
|
|
30
|
+
## Common Pitfalls
|
|
31
|
+
- Never use `unwrap()` or `expect()` in production paths — propagate errors with `?` instead.
|
|
32
|
+
- Avoid `clone()` as a workaround for borrow-checker conflicts; restructure ownership or use a reference instead.
|
|
33
|
+
- Do not hold a `MutexGuard` across an `await` point — drop it explicitly before awaiting.
|
|
34
|
+
|
|
35
|
+
## Review Checklist
|
|
36
|
+
- [ ] No `unwrap()` / `expect()` in non-test production code.
|
|
37
|
+
- [ ] No `clone()` used to paper over borrow-checker issues.
|
|
38
|
+
- [ ] Explicit lifetime annotations present only where elision fails.
|
|
39
|
+
- [ ] `Mutex` guards released before any `.await` points.
|
|
40
|
+
- [ ] `Arc<Mutex<T>>` used for all cross-thread mutable state.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testing
|
|
3
|
+
description: Rust unit, async, integration, and property-based testing with cargo test, tokio::test, and proptest.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Rust Testing
|
|
7
|
+
|
|
8
|
+
## Testing Principles
|
|
9
|
+
- Test observable behavior through public interfaces, not internal implementation details.
|
|
10
|
+
- Follow the **Arrange-Act-Assert (AAA)** pattern in every test.
|
|
11
|
+
- Keep tests isolated, deterministic, and independent of execution order or external state.
|
|
12
|
+
|
|
13
|
+
## Unit Tests
|
|
14
|
+
- Place unit tests in the same file as the code under test inside a `#[cfg(test)]` module:
|
|
15
|
+
```rust
|
|
16
|
+
#[cfg(test)]
|
|
17
|
+
mod tests {
|
|
18
|
+
use super::*;
|
|
19
|
+
|
|
20
|
+
#[test]
|
|
21
|
+
fn create_user_valid_input_returns_ok() {
|
|
22
|
+
// Arrange / Act / Assert
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
- Use descriptive names: `fn <function>_<scenario>_<expected>`.
|
|
27
|
+
|
|
28
|
+
## Async Tests
|
|
29
|
+
- Use `#[tokio::test]` for async test functions:
|
|
30
|
+
```rust
|
|
31
|
+
#[tokio::test]
|
|
32
|
+
async fn fetch_user_not_found_returns_error() { ... }
|
|
33
|
+
```
|
|
34
|
+
- Mock async I/O boundaries with `mockall` (`#[automock]`) — never hit real services in unit tests.
|
|
35
|
+
|
|
36
|
+
## Integration Tests
|
|
37
|
+
- Place integration tests in the top-level `tests/` directory; each file is a separate test binary.
|
|
38
|
+
- Use `common/mod.rs` (or `common.rs`) under `tests/` for shared test helpers and fixtures.
|
|
39
|
+
- Run with `cargo test --test <name>`.
|
|
40
|
+
|
|
41
|
+
## Property-Based Testing
|
|
42
|
+
- Use `proptest` for algorithmic and parsing logic where exhaustive edge-case enumeration is impractical.
|
|
43
|
+
```rust
|
|
44
|
+
proptest! {
|
|
45
|
+
#[test]
|
|
46
|
+
fn parse_roundtrip(s in "\\PC*") { ... }
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Mocking
|
|
51
|
+
- Use `mockall` to generate mocks for traits: annotate the trait with `#[automock]` and import `MockMyTrait` in tests.
|
|
52
|
+
- Verify expectations explicitly with `.expect(n)` or `.times(n)` on mock methods.
|
|
53
|
+
|
|
54
|
+
## Running Tests
|
|
55
|
+
```bash
|
|
56
|
+
cargo test # all tests
|
|
57
|
+
cargo test --lib # unit tests only
|
|
58
|
+
cargo test --test integration # integration tests only
|
|
59
|
+
cargo test -- --nocapture # show stdout during tests
|
|
60
|
+
```
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Workflow
|
|
4
4
|
1. **Memory & Context**: Read `AgentSkills/memory/index.md` (create if missing); load only relevant domain lessons to avoid repeating past mistakes.
|
|
5
|
-
2. **Role & Skill Discovery**:
|
|
5
|
+
2. **Role & Skill Discovery**: Consult `AgentSkills/skills/index.md` to identify and load task-specific skills from `AgentSkills/skills/` (including `AgentSkills/skills/review/SKILL.md`). Load relevant role guidance from `AgentSkills/agents/` (`architect.md`, `reviewer.md`, `developer.md`).
|
|
6
6
|
3. **Pre-flight Inspection**: Inspect current codebase patterns, dependencies, and baseline build/test state.
|
|
7
7
|
4. **Surgical Implementation**: Apply the minimal change required; adhere strictly to DRY, KISS, and YAGNI.
|
|
8
|
-
5. **Verification**: Run the project's build and test commands (e.g. `npm test`, `dotnet test`, or project test suite) to verify happy paths and edge cases per `AgentSkills/skills/review/SKILL.md`.
|
|
8
|
+
5. **Verification**: Run the project's build and test commands (e.g. `npm test`, `dotnet test`, `cargo test`, `uv run pytest`, or project test suite) to verify happy paths and edge cases per `AgentSkills/skills/review/SKILL.md`.
|
|
9
9
|
6. **Learning Loop**: If a mistake was made and corrected or a durable rule discovered, record a concise lesson in `AgentSkills/memory/lessons/<domain>.md` and update `index.md`.
|
|
10
10
|
|
|
11
11
|
## Completion Checklist
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Skills Index
|
|
2
|
+
|
|
3
|
+
Consult this index to load only the skills relevant to the current task.
|
|
4
|
+
|
|
5
|
+
| Skill | Path | Description / When to Load |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| principles | AgentSkills/skills/principles/SKILL.md | Foundational simplicity ladder, KISS, YAGNI, surgical changes |
|
|
8
|
+
| standards | AgentSkills/skills/standards/SKILL.md | Code quality, 50-line limits, shallow nesting, clean signatures |
|
|
9
|
+
| security | AgentSkills/skills/security/SKILL.md | Input validation, secrets handling, safe queries, least privilege |
|
|
10
|
+
| review | AgentSkills/skills/review/SKILL.md | Code review framework, five review dimensions, verification rules |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: standards
|
|
3
|
-
description: Core code quality, complexity limits, naming, and structural conventions.
|
|
3
|
+
description: Core code quality, simplicity, complexity limits, naming, and structural conventions.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Code Standards
|
|
@@ -11,11 +11,20 @@ description: Core code quality, complexity limits, naming, and structural conven
|
|
|
11
11
|
- **Clean Signatures**: Maximum 4 parameters per function; use an options object or record for complex signatures.
|
|
12
12
|
|
|
13
13
|
## Design & Clean Code
|
|
14
|
-
- **
|
|
14
|
+
- **Simplicity First (KISS / YAGNI)**: Favor simple, clear, maintainable solutions over clever abstractions. Do not add unrequested features.
|
|
15
|
+
- **SOLID / DRY**: Single-responsibility components; eliminate duplicated logic; prefer clear, direct implementations over speculative abstractions (YAGNI).
|
|
16
|
+
- **Less is more**: Avoid over-engineering; prefer fewer moving parts and simpler designs.
|
|
17
|
+
- **Consistent Style**: Follow the repository's style guide; use linters and formatters to enforce consistency.
|
|
18
|
+
- **Configuration & Defaults**: Provide sensible defaults and configuration options; avoid hardcoding values.
|
|
19
|
+
- **separation of Concerns**: Keep business logic, data access, and presentation layers distinct; avoid mixing responsibilities.
|
|
20
|
+
- **Modular Design**: Break down large components into smaller, reusable modules; prefer composition over inheritance.
|
|
21
|
+
- **Dependency Management**: Minimize external dependencies; prefer standard libraries and well-maintained packages; avoid unnecessary bloat.
|
|
22
|
+
- **self-Documenting Code**: Write code that is clear and understandable without excessive comments; use meaningful names and expressive constructs.
|
|
23
|
+
- **security & Privacy**: Follow best practices for secure coding; validate inputs, sanitize outputs, and protect sensitive data.
|
|
15
24
|
- **Naming & Clarity**: Use descriptive, domain-meaningful names for classes, functions, and variables.
|
|
16
25
|
- **No Magic Literals**: Replace magic numbers and strings with named constants or enums.
|
|
17
26
|
- **Contracts & Schemas**: Design explicit, human- and machine-readable data contracts, schemas, and self-describing APIs.
|
|
18
|
-
- **Intentional Comments**: Comment only where non-obvious rationale is required, never restate what the code itself expresses.
|
|
27
|
+
- **Intentional Comments**: Comment only where non-obvious rationale is required, never restate what the code itself expresses. Comments should explain "why" not "what". CODE SHOULD BE SELF-DESCRIBING.
|
|
19
28
|
|
|
20
29
|
## Concurrency & Safety
|
|
21
30
|
- **Async Safety**: Use idiomatic non-blocking `async`/`await`; ensure operations are free of race conditions and deadlocks.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> Operating instructions and engineering guidelines for AI agents and human contributors.
|
|
4
4
|
|
|
5
5
|
## Operating Contract
|
|
6
|
-
Always follow `AgentSkills/OPERATING.md` before making changes.
|
|
6
|
+
Always follow `AgentSkills/OPERATING.md` before making changes. Consult `AgentSkills/skills/index.md` to load task-relevant skills (including `AgentSkills/skills/review/SKILL.md`), and review relevant agent personas in `AgentSkills/agents/` (`architect.md`, `reviewer.md`, `developer.md`).
|
|
7
7
|
|
|
8
8
|
## Goal
|
|
9
9
|
Implement requested changes with production-quality code, preserving existing behavior and
|
|
@@ -20,7 +20,7 @@ minimizing the diff, following the project's own architecture, standards, and co
|
|
|
20
20
|
- **Zero-Error Builds**: Every change must compile cleanly and pass existing and newly added tests.
|
|
21
21
|
|
|
22
22
|
## Definition of Done
|
|
23
|
-
- Builds cleanly
|
|
23
|
+
- Builds cleanly without any errors.
|
|
24
24
|
- No debug code, dead code, unused imports, or temporary files left behind.
|
|
25
25
|
- Changes are minimal, focused, covered by tests, and easy to review.
|
|
26
26
|
|