skills/backend-test/SKILL.md
Generate backend tests (unit, integration, mocks) for existing code. Auto-invoke when user says "write test for", "add test", "test this", or "create test".
npx skillsauth add alekspetrov/navigator backend-testInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Generate backend tests for existing code — typically code that was written without tests, or where additional coverage is needed beyond what a code-writing skill (backend-endpoint) already produced.
When to use this vs.
backend-endpoint:backend-endpointgenerates tests as part of creating a new endpoint. Usebackend-testwhen the code already exists and you need to add or expand its tests.
Auto-invoke when user says:
Query the knowledge graph for what we know about testing in this project:
PLUGIN_DIR="${CLAUDE_PLUGIN_DIR:-$HOME/.claude/plugins/cache/navigator-marketplace/navigator}"
[ -d "$PLUGIN_DIR" ] || PLUGIN_DIR="$HOME/.claude/plugins/marketplaces/navigator-marketplace"
python3 "$PLUGIN_DIR/skills/nav-graph/functions/graph_manager.py" \
--action query --concept testing \
--graph-path .agent/knowledge/graph.json 2>/dev/null | head -40
Surface patterns (preferred frameworks, mocking conventions) and pitfalls (flaky-test gotchas). If the graph returns nothing, proceed without it.
If the user named a specific file, use it. Otherwise, ask:
What should I test?
- File path (e.g., src/services/userService.ts)
- Function name (e.g., authenticateUser)
- API endpoint (e.g., POST /api/login)
Read the target file in full so the generated tests cover its actual behavior, not assumed behavior.
# Jest
grep -q '"jest"' package.json 2>/dev/null && echo "Jest detected"
# Vitest
grep -q '"vitest"' package.json 2>/dev/null && echo "Vitest detected"
# Mocha
grep -q '"mocha"' package.json 2>/dev/null && echo "Mocha detected"
# Node test runner (built-in)
[ -f "package.json" ] && grep -q '"test":\s*"node --test' package.json && echo "node:test detected"
Detect existing test patterns by reading a peer test file under __tests__/, tests/, or *.test.ts alongside the target.
File location: place tests where existing tests live (mirror the project's convention — colocated *.test.ts next to source, or under a tests/ directory).
Structure (Jest/Vitest):
import { describe, it, expect, beforeEach, vi } from 'vitest'; // or 'jest'
import { {FUNCTION_NAME} } from '{TARGET_PATH}';
describe('{FUNCTION_NAME}', () => {
describe('happy path', () => {
it('returns expected result for valid input', () => {
const result = {FUNCTION_NAME}({VALID_INPUT});
expect(result).toEqual({EXPECTED});
});
});
describe('error cases', () => {
it('throws on invalid input', () => {
expect(() => {FUNCTION_NAME}({INVALID_INPUT})).toThrow();
});
});
describe('edge cases', () => {
it('handles empty input', () => { /* ... */ });
it('handles boundary values', () => { /* ... */ });
});
});
For API/integration tests (supertest pattern):
import request from 'supertest';
import { app } from '{APP_PATH}';
describe('{METHOD} {PATH}', () => {
it('returns 200 for valid request', async () => {
const response = await request(app).{method}('{PATH}').send({BODY});
expect(response.status).toBe(200);
expect(response.body).toMatchObject({EXPECTED_SHAPE});
});
it('returns 4xx for invalid request', async () => {
const response = await request(app).{method}('{PATH}').send({BAD_BODY});
expect(response.status).toBe(400);
});
});
Run the generated tests:
{TEST_COMMAND} {TEST_FILE_PATH}
If any fail because tests assume incorrect behavior, fix the tests, not the source — unless the source has an actual bug. If the source is buggy, surface that to the user; don't silently change it.
{
"execution_summary": {
"skill": "backend-test",
"task": "tests for {TARGET}",
"files_created": ["{test file path}"],
"files_modified": [],
"tests_added": ["{test file path}"],
"stack_detected": "{e.g. vitest+supertest}",
"patterns_followed": [
{"summary": "{e.g. supertest pattern for HTTP integration tests}", "concepts": ["testing", "api"], "confidence": 0.8}
],
"decisions_made": [
{"summary": "{e.g. mocked the DB client because tests must run offline}", "concepts": ["testing"], "confidence": 0.75}
],
"pitfalls_avoided": [],
"assumptions_made": ["{e.g. project uses Vitest globals — no explicit import needed}"]
}
}
Ingest:
PLUGIN_DIR="${CLAUDE_PLUGIN_DIR:-$HOME/.claude/plugins/cache/navigator-marketplace/navigator}"
[ -d "$PLUGIN_DIR" ] || PLUGIN_DIR="$HOME/.claude/plugins/marketplaces/navigator-marketplace"
echo '<execution_summary JSON>' | python3 "$PLUGIN_DIR/skills/nav-graph/functions/execution_to_graph.py" -
backend-endpoint (it generates tests as part of its workflow)frontend-testtools
Sync project CLAUDE.md to the installed Navigator version, preserving customizations. Use when user says "sync CLAUDE.md", "update CLAUDE.md", or when detecting outdated Navigator configuration.
tools
Automates design review, token extraction, component mapping, and implementation planning. Reduces design handoff from 6-10 hours to 5 minutes via direct Figma MCP integration. Auto-invoke when user mentions design review, Figma mockup, or design handoff.
tools
Automates Navigator plugin updates. Detects current version, updates plugin, verifies installation, updates project CLAUDE.md, and validates new features. Auto-invoke when user mentions upgrading Navigator or getting new features.
documentation
Manage Navigator task documentation - create implementation plans, archive completed tasks, update task index. Use when user starts new feature, completes work, or says "document this feature".