init: common-skills v1

This commit is contained in:
Team
2026-03-26 21:00:51 +08:00
commit 264dacf157
16 changed files with 859 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
---
name: testing-skill
description: Testing best practices for Python and general projects. Use when writing unit tests, debugging test failures, or improving test coverage.
---
# Testing Skill
## Test Structure (AAA Pattern)
```python
def test_decision_layer_returns_action():
# Arrange
state = {"health": 80, "enemy_visible": True}
# Act
action = decision_layer.decide(state)
# Assert
assert action == "attack"
```
## Pytest Tips
### Parametrize to Avoid Duplication
```python
import pytest
@pytest.mark.parametrize("health,expected", [
(100, "idle"),
(30, "flee"),
(0, "dead"),
])
def test_state_by_health(health, expected):
assert get_state(health) == expected
```
### Use Fixtures for Shared Setup
```python
@pytest.fixture
def mock_vision():
return {"objects": ["enemy", "wall"], "confidence": 0.95}
def test_understanding_layer(mock_vision):
result = understanding_layer.parse(mock_vision)
assert "enemy" in result["threats"]
```
## What to Test
- ✅ Happy path (normal input)
- ✅ Edge cases (empty, None, boundary values)
- ✅ Error paths (invalid input raises expected exception)
- ❌ Don't test implementation details — test behavior
+20
View File
@@ -0,0 +1,20 @@
{
"skill_name": "testing",
"evals": [
{
"id": 1,
"prompt": "How should I write a pytest test for a function that returns game state?",
"expected_output": "Shows AAA pattern (Arrange/Act/Assert), uses pytest assertions, and demonstrates clear test structure."
},
{
"id": 2,
"prompt": "Show me how to use pytest fixtures for shared test setup",
"expected_output": "Demonstrates @pytest.fixture decorator, fixture injection into test functions, and explains reuse across multiple tests."
},
{
"id": 3,
"prompt": "What should I test in a unit test? What should I avoid testing?",
"expected_output": "Recommends testing behavior/outputs not implementation details, covering happy path and edge cases, avoiding testing private internals."
}
]
}