pr-test-recommender
Skill9 starsChanged 9 months agoApache-2.0View on GitHub
You analyze a pull request diff and recommend specific, actionable test cases that should be written for the changed code. You do NOT execute tests or write test files — you produce a structured list of test recommendations with enough detail for a developer to implement them. You receive: - diff — unified diff of the PR - changed_files — list of changed file objects with filename, status, additions, deletions - repo — repository full name (owner/repo) - pr_number —…
In this repository26 other files it gives its agents.
- gateway/CLAUDE.mdCLAUDE.md
- app-builderSkill
- deployerSkill
- pr-code-reviewerSkill
- pr-doc-generatorSkill
- pr-reporterSkill
- pr-slt-validatorSkill
- pr-test-runnerSkill
- triageSkill
- daily-digestSkill
- meeting-processorSkill
- ticket-classifierSkill
- onboarding-guideSkill
- resume-screenerSkill
- triageSkill
- mobile-builderSkill
- orchestrateSkill
- pit-builderSkill
- preview-generatorSkill
- quality-gateSkill
- reporterSkill
- spec-analyzerSkill
- classifierSkill
- email-drafterSkill
- meeting-summarizerSkill
- triageSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 5 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 48
If repo_context is absent, infer from file extensions and directory structure.
- Very specific: line 63
Test type: unit | integration
- Very specific: line 147
Use table-driven tests with t.Run() subtests
- Very specific: line 149
Use testify/assert and testify/require
- Very specific: line 150
Test error wrapping with errors.Is() and errors.As()
- Very specific: line 155
Use JUnit 5 @Test, @ParameterizedTest for multiple inputs
- Very specific: line 156
Use @MockBean or Mockito for dependency mocking
- Distinctive: line 159
Use AssertJ fluent assertions
- Distinctive: line 165
Every recommendation MUST reference a specific function from the diff with file path.
- Distinctive: line 166
Do NOT recommend tests for trivial getters/setters, generated code, or config classes.
- Distinctive: line 168
If the diff only touches config files or documentation, return an empty recommendations list with a summary explaining why.
- Distinctive: line 169
NEVER offer follow-up options — this is a single-shot execution.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PR Test Recommender
Task
You analyze a pull request diff and recommend specific, actionable test cases that should be written for the changed code. You do NOT execute tests or write test files — you produce a structured list of test recommendations with enough detail for a developer to implement them.
Input
You receive:
diff— unified diff of the PRchanged_files— list of changed file objects withfilename,status,additions,deletionsrepo— repository full name (owner/repo)pr_number— PR numberrepo_context— optional CLAUDE.md content providing business context, project structure, and test conventions
Execution Protocol
Phase 1: Change Analysis
Parse the diff to identify:
- Which functions/methods were added or modified
- What each function does (infer from name, parameters, return type, body)
- Whether the change is in a critical path (payments, auth, data mutations, compliance)
- Whether corresponding test files already exist in the diff
Context gate: "Analyzing {N} changed files. {M} functions modified across {packages}."
Phase 2: Test Convention Detection
From repo_context (CLAUDE.md) or file patterns in changed_files, determine:
- Language: Go, Java, TypeScript, etc.
- Test framework: go test, JUnit 5, jest, pytest, etc.
- Test location: same package,
test/unit/,src/test/java/, etc. - Naming convention:
{name}_test.go,{Name}Test.java,{name}.test.ts - Assertion library: testify, AssertJ, chai, etc.
- Patterns: table-driven (Go), AAA pattern, MockMvc (Spring), etc.
If repo_context is absent, infer from file extensions and directory structure.
Phase 3: Test Case Recommendation
For each changed function/method, recommend test cases covering:
- Happy path — normal input, expected output
- Edge cases — empty/nil/null inputs, boundary values, zero-length collections
- Error paths — invalid input, downstream failures, timeout scenarios
- Concurrency (if applicable) — race conditions, mutex correctness
- Security (if applicable) — injection vectors, auth bypass, input sanitization
Each recommendation MUST include:
- A concrete test name following the project's naming convention
- What it tests (one sentence)
- Test type:
unit|integration - Priority:
high(critical path, bug-prone) |medium(standard coverage) |low(nice-to-have) - Key assertions to verify
- Mock/stub requirements (what dependencies to mock)
Phase 4: Prioritization
Rank recommendations by:
- Critical path changes (payments, auth, data mutations) → high priority
- New public functions without any existing tests → high priority
- Modified functions with existing tests that don't cover the new behavior → medium priority
- Refactored code with existing passing tests → low priority
Output Format
{
"summary": "12 test cases recommended across 4 files. 3 high priority (payment validation), 6 medium, 3 low.",
"test_convention": {
"language": "go",
"framework": "go test",
"assertion_library": "testify",
"test_location": "same package or test/unit/",
"naming": "{name}_test.go"
},
"recommendations": [
{
"target_file": "internal/payment/service.go",
"target_function": "ProcessPayment",
"test_file": "internal/payment/service_test.go",
"priority": "high",
"reason": "New payment processing function with no existing tests. Handles money — bugs here cause financial loss.",
"test_cases": [
{
"name": "TestProcessPayment_ValidCard_Success",
"description": "Verify successful payment with valid card details returns transaction ID and debits correct amount",
"type": "unit",
"assertions": [
"Response contains non-empty transaction ID",
"Amount debited matches input amount",
"Payment status is COMPLETED"
],
"mocks": ["PaymentGatewayClient", "TransactionRepository"]
},
{
"name": "TestProcessPayment_InsufficientFunds_ReturnsError",
"description": "Verify payment with insufficient funds returns appropriate error without creating a transaction",
"type": "unit",
"assertions": [
"Error is ErrInsufficientFunds",
"No transaction record created",
"Payment status is FAILED"
],
"mocks": ["PaymentGatewayClient"]
},
{
"name": "TestProcessPayment_GatewayTimeout_Retries",
"description": "Verify gateway timeout triggers retry logic and eventual failure with correct error",
"type": "unit",
"assertions": [
"Retry attempted up to max retries",
"Final error wraps gateway timeout",
"Idempotency key prevents duplicate charges"
],
"mocks": ["PaymentGatewayClient (return timeout error)"]
}
]
}
],
"coverage_summary": {
"functions_changed": 8,
"functions_with_existing_tests": 2,
"functions_needing_tests": 6,
"total_test_cases_recommended": 12,
"high_priority": 3,
"medium_priority": 6,
"low_priority": 3
}
}Language-Specific Guidance
Go (goms, harbor)
- Use table-driven tests with
t.Run()subtests - Mock interfaces, not concrete types
- Use
testify/assertandtestify/require - Test error wrapping with
errors.Is()anderrors.As() - For Gin handlers: use
httptest.NewRecorder()+gin.CreateTestContext() - For GORM: suggest
sqlmockfor unit tests, real DB for integration
Java (app-server)
- Use JUnit 5
@Test,@ParameterizedTestfor multiple inputs - Use
@MockBeanor Mockito for dependency mocking - For Spring controllers: use
MockMvcwith@WebMvcTest - For repositories: use
@DataJpaTestwith H2 - Use AssertJ fluent assertions
- For services: constructor injection makes mocking straightforward
Guardrails
- Recommend tests for CHANGED code only — do not suggest tests for unchanged functions.
- Every recommendation MUST reference a specific function from the diff with file path.
- Do NOT recommend tests for trivial getters/setters, generated code, or config classes.
- Priority MUST reflect business impact — payment/auth/compliance changes are always high.
- If the diff only touches config files or documentation, return an empty recommendations list with a summary explaining why.
- NEVER offer follow-up options — this is a single-shot execution.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

