一键导入
be-testing
Backend testing patterns — API request construction, response verification, database state checks, error handling testing, and adaptive tool detection.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Backend testing patterns — API request construction, response verification, database state checks, error handling testing, and adaptive tool detection.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when designing, authoring, or reviewing a closed agent loop (test→fix→retest, audit→fix→re-audit, generate→verify→correct) in this marketplace — the minimum-bar checklist, the ground-truth oracle taxonomy, and the anti-patterns, anchored to /qa:loop as the reference implementation.
Test report format with QA-XXX issue IDs compatible with code-review plugin. Defines report structure, severity levels, issue format, and detailed results.
Bun package management, lockfile policy, workspaces, CI integration, and Bun-native tooling
Frontend testing patterns using Playwright MCP — navigation, interaction, assertions, screenshots on failure, and common UI testing scenarios.
Test plan structure, naming conventions, edge case generation rules, and file saving conventions for QA test plans.
Security scanning templates and HARD-RULES for CI/CD pipeline configuration. Covers Semgrep SAST and TruffleHog secret scanning across Bitbucket, GitHub Actions, GitLab CI, and Azure DevOps.
| name | be-testing |
| description | Backend testing patterns — API request construction, response verification, database state checks, error handling testing, and adaptive tool detection. |
| allowed-tools | Bash(curl:*), Bash(httpie:*), Bash(http:*), Bash(wget:*), Bash(psql:*), Bash(sqlite3:*), Bash(mysql:*), Bash(mongosh:*), Bash(redis-cli:*), Bash(command:*), Bash(echo:*), Bash(jq:*), Bash(grep:*), Bash(cat:*), Bash(head:*), Bash(tail:*), Read, Write, Bash(mkdir:*) |
ALWAYS run this check first:
# HTTP clients
command -v curl >/dev/null 2>&1 && echo "OK: curl available" || echo "UNAVAILABLE: curl"
command -v http >/dev/null 2>&1 && echo "OK: httpie available" || echo "UNAVAILABLE: httpie"
# Database clients
command -v psql >/dev/null 2>&1 && echo "OK: psql available" || echo "UNAVAILABLE: psql"
command -v sqlite3 >/dev/null 2>&1 && echo "OK: sqlite3 available" || echo "UNAVAILABLE: sqlite3"
command -v mysql >/dev/null 2>&1 && echo "OK: mysql available" || echo "UNAVAILABLE: mysql"
command -v mongosh >/dev/null 2>&1 && echo "OK: mongosh available" || echo "UNAVAILABLE: mongosh"
command -v redis-cli >/dev/null 2>&1 && echo "OK: redis-cli available" || echo "UNAVAILABLE: redis-cli"
# JSON processing
command -v jq >/dev/null 2>&1 && echo "OK: jq available" || echo "UNAVAILABLE: jq"
Use the first available tool from each category. If no HTTP client is available, mark all API scenarios as SKIP.
In addition to CLI tools, check if any database or API-related MCP servers are available. MCP servers provide direct access without needing CLI clients installed locally.
Common database MCP servers:
mcp__postgres, mcp__supabase, mcp__neon or similarmcp__mysql or similarmcp__mongodb or similarmcp__redis or similarCommon API-related MCP servers:
How to detect: Check the available tools list in your session. MCP tools follow the pattern mcp__<server>__<tool>. If you see database-related MCP tools, prefer them over CLI clients — they're typically pre-configured with connection details and don't require manual connection string setup.
Priority order for DB access:
For each BE scenario from the test plan:
GET request:
curl -s -w "\n%{http_code}" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
"http://localhost:8000/api/resources"
POST request:
curl -s -w "\n%{http_code}" \
-X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "test", "email": "test@example.com"}' \
"http://localhost:8000/api/resources"
PUT request:
curl -s -w "\n%{http_code}" \
-X PUT \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "updated"}' \
"http://localhost:8000/api/resources/1"
DELETE request:
curl -s -w "\n%{http_code}" \
-X DELETE \
-H "Authorization: Bearer $TOKEN" \
"http://localhost:8000/api/resources/1"
PATCH request:
curl -s -w "\n%{http_code}" \
-X PATCH \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"status": "active"}' \
"http://localhost:8000/api/resources/1"
The -w "\n%{http_code}" flag appends the status code on a new line after the response body. Parse the last line as the status code.
GET request:
http GET http://localhost:8000/api/resources \
Authorization:"Bearer $TOKEN" \
--print=hb
POST request:
http POST http://localhost:8000/api/resources \
Authorization:"Bearer $TOKEN" \
name=test email=test@example.com \
--print=hb
Use --print=hb to show headers and body (useful for debugging). Use --print=b for body only.
Check status code:
STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X GET "http://localhost:8000/api/resources")
if [ "$STATUS" = "200" ]; then echo "PASS: status 200"; else echo "FAIL: expected 200, got $STATUS"; fi
Check response body with jq:
RESPONSE=$(curl -s -H "Content-Type: application/json" "http://localhost:8000/api/resources")
# Check field exists and has value
echo "$RESPONSE" | jq -e '.id' > /dev/null 2>&1 && echo "PASS: id exists" || echo "FAIL: id missing"
# Check specific value
echo "$RESPONSE" | jq -e '.status == "active"' > /dev/null 2>&1 && echo "PASS: status is active" || echo "FAIL: status mismatch"
# Check array length
echo "$RESPONSE" | jq -e '.items | length > 0' > /dev/null 2>&1 && echo "PASS: items not empty" || echo "FAIL: items empty"
Without jq (fallback with grep):
RESPONSE=$(curl -s "http://localhost:8000/api/resources")
echo "$RESPONSE" | grep -q '"status":"active"' && echo "PASS" || echo "FAIL"
# Check record exists
psql -h localhost -U user -d dbname -t -A -c "SELECT COUNT(*) FROM resources WHERE name = 'test';"
# Expected: 1
# Check field value
psql -h localhost -U user -d dbname -t -A -c "SELECT status FROM resources WHERE id = 1;"
# Expected: active
# Check record was deleted
psql -h localhost -U user -d dbname -t -A -c "SELECT COUNT(*) FROM resources WHERE id = 1;"
# Expected: 0
# Check with multiple conditions
psql -h localhost -U user -d dbname -t -A -c "SELECT COUNT(*) FROM orders WHERE user_id = 1 AND status = 'completed';"
Flags: -t (tuples only, no headers), -A (unaligned output, no padding).
# Check record exists
sqlite3 db.sqlite3 "SELECT COUNT(*) FROM resources WHERE name = 'test';"
# Check field value
sqlite3 db.sqlite3 "SELECT status FROM resources WHERE id = 1;"
# Check record exists
mysql -h localhost -u user -ppassword dbname -N -e "SELECT COUNT(*) FROM resources WHERE name = 'test';"
Flag: -N (skip column names).
If the test plan doesn't specify DB connection details, look for them in:
.env or .env.local filesdocker-compose.yml (service ports, credentials)settings.py, database.yml, config/database.php)DATABASE_URL, DB_HOST, DB_NAME, DB_USER, DB_PASSWORD# Send request without required field
curl -s -w "\n%{http_code}" -X POST \
-H "Content-Type: application/json" \
-d '{"name": "test"}' \
"http://localhost:8000/api/resources"
# Expected: 422 with validation error in body
# Send request without auth token
curl -s -w "\n%{http_code}" -X GET \
"http://localhost:8000/api/resources"
# Expected: 401
# Send request with regular user token to admin endpoint
curl -s -w "\n%{http_code}" -X DELETE \
-H "Authorization: Bearer $REGULAR_USER_TOKEN" \
"http://localhost:8000/api/admin/users/1"
# Expected: 403
curl -s -w "\n%{http_code}" -X GET \
-H "Authorization: Bearer $TOKEN" \
"http://localhost:8000/api/resources/99999"
# Expected: 404
# Create resource
curl -s -X POST -H "Content-Type: application/json" \
-d '{"email": "test@example.com"}' \
"http://localhost:8000/api/users"
# Try to create duplicate
curl -s -w "\n%{http_code}" -X POST -H "Content-Type: application/json" \
-d '{"email": "test@example.com"}' \
"http://localhost:8000/api/users"
# Expected: 409
For each scenario, return results in this format:
### BE-XX: <scenario name>
- **Status:** PASS / FAIL / SKIP
- **Request:** <METHOD> <URL>
- **Response status:** <actual status code>
- **Response body:** <relevant excerpt or full body if short>
- **DB check:** <PASS/FAIL/SKIP — actual value vs expected>
- **Details:** <what was verified / what went wrong>
- **Edge cases:**
- <edge case 1>: PASS / FAIL — <details>
- <edge case 2>: PASS / FAIL — <details>