用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill fastapi-run-backend-tests命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | fastapi-run-backend-tests |
| description | > Use when this capability is needed. |
Run pytest with smart defaults and short-name resolution.
Arguments: $ARGUMENTS
Locate the project's backend directory by scanning for common indicators:
# Collect ALL matching backend directories (don't break on first)
MATCHES=""
for dir in backend server app api src; do
if [ -d "$dir" ] && { [ -f "$dir/conftest.py" ] || [ -d "$dir/tests" ]; }; then
MATCHES="$MATCHES $dir"
fi
done
# Fallback: check for conftest.py or tests/ at project root
if [ -f "conftest.py" ] || [ -d "tests" ]; then
MATCHES="$MATCHES ."
fi
echo "Detected: $MATCHES"
If multiple directories found, present the list and ask the user to choose. Do not silently pick the first match — monorepos may have multiple test-bearing directories.
If a short name is given (e.g., auth), resolve it to a full test file path:
# Search by short name pattern
find {backend_dir}/tests -name "*${NAME}*.py" -type f 2>/dev/null
# Search by function name if --func given
grep -rl "def test_${FUNC}" {backend_dir}/tests/ 2>/dev/null
Resolution priority:
test_*.py or *_test.py files--func) → grep across test files to find containing file{backend_dir}/tests/cd {backend_dir} && PYTHONPATH=. pytest {path} -v --tb=short {flags}
| Argument | pytest Flag | Purpose |
|---|---|---|
--coverage | --cov=app --cov-report=term-missing | Show coverage with uncovered lines |
--collect-only | --collect-only -q | List test names without running |
-x | -x | Stop on first failure |
--file <name> | Resolved path | Run specific file |
--func <name> | -k <name> | Run tests matching name pattern |
# Run all tests
PYTHONPATH=. pytest tests/ -v --tb=short
# Run with coverage
PYTHONPATH=. pytest tests/ -v --cov=app --cov-report=term-missing
# Run specific test file by short name
PYTHONPATH=. pytest tests/test_auth.py -v --tb=short
# Run specific test function
PYTHONPATH=. pytest tests/test_auth.py::test_login_success -v --tb=short
# Run tests matching a keyword
PYTHONPATH=. pytest tests/ -v -k "auth and not admin"
# List tests without running
PYTHONPATH=. pytest tests/ --collect-only -q
Backend Tests: PASSED — {N} passed in {duration}s
If --coverage was used, include coverage summary:
Coverage: {X}% overall | {Y}% app/ | {Z}% models/
Uncovered: app/routes/admin.py:45-67, app/services/email.py:23-31
Backend Tests: FAILED — {N} passed, {M} failed
Failed Tests:
tests/test_auth.py::test_login_expired_token — AssertionError: 401 != 200
tests/test_users.py::test_create_duplicate — IntegrityError
Auto-invoking /fix-loop (STEP 7)...
Categorize failures using these standard categories:
ASSERTION_FAILURE — expected vs actual mismatchRUNTIME_EXCEPTION — unhandled exceptionFIXTURE_MISMATCH — setup/teardown issueMISSING_IMPORT — import not foundTIMEOUT — test exceeded time limit| Result | Action |
|---|---|
| All passed | Report success, suggest broader suite if only subset was run |
| Failures found | Auto-invoke /fix-loop (see STEP 7) |
| Coverage below 80% | Highlight uncovered files, suggest /tdd-failing-test-generator for gap filling |
| Flaky tests detected | Suggest re-running with --count=3 (pytest-repeat) to confirm |
Write machine-readable results to test-results/fastapi-run-backend-tests.json:
{
"skill": "fastapi-run-backend-tests",
"result": "PASSED|FAILED",
"timestamp": "<ISO-8601>",
"tests_run": "<total_count>",
"tests_failed": "<failed_count>",
"failures": [
{
"test": "<test_file>::<test_function>",
"category": "ASSERTION_FAILURE|RUNTIME_EXCEPTION|FIXTURE_MISMATCH|MISSING_IMPORT|TIMEOUT",
"file": "<test_file_path>:<line>",
"message": "<error_message>"
}
]
}
Create test-results/ directory if it doesn't exist. This JSON is consumed by downstream stage gates.
mkdir -p test-results
python3 -c "
import json, datetime
result = {
'skill': 'fastapi-run-backend-tests',
'result': '<PASSED_or_FAILED>',
'timestamp': datetime.datetime.now(datetime.timezone.utc).isoformat(),
'tests_run': '<N>',
'tests_failed': '<N>',
'failures': []
}
with open('test-results/fastapi-run-backend-tests.json', 'w') as f:
json.dump(result, f, indent=2)
"
If tests failed in STEP 4, automatically invoke the fix-and-learn pipeline. Do NOT just suggest — invoke directly.
Failure-count guard: If >10 test failures, report the count to the user and ask before auto-invoking /fix-loop — mass failures usually indicate an environment issue or broken import, not 10+ independent bugs. Fixing blindly wastes iterations and risks cascading changes.
Skill("fix-loop", args="<failure_output>\n\nretest_command: cd {backend_dir} && PYTHONPATH=. pytest {resolved_path} -v --tb=short -x")
This iterates: analyze → fix → retest until green (max 5 iterations).
If /fix-loop reports result: PASSED or result: FIXED:
Skill("learn-n-improve", args="session")
If /learn-n-improve is not available in this project, skip this step silently.
If /fix-loop exhausts 5 iterations without success:
/systematic-debugging for deeper investigationDo NOT auto-invoke fix-loop if:
--collect-only was used (no actual test execution)backend/PYTHONPATH=. to ensure cross-module imports work--tb=short for readable output (unless user requests --tb=long)/fix-loop on failure — do not just suggest itbackend/ — detect itPYTHONPATH=. — imports will breakSource: abhayla/claude-best-practices — distributed by TomeVault.