Use this skill when creating a new Java E2E integration test (failsafe IT) that requires a new replay proxy YAML snapshot file in test/snapshots/
npx skills add https://github.com/github/copilot-sdk --skill new-java-e2e-test-yaml-and-test
This skill covers the complete workflow for adding a new Java failsafe
integration test backed by a handcrafted YAML snapshot for the replay proxy.
The Java E2E tests use a replay proxy (test/harness/replayingCapiProxy.ts)
that intercepts HTTP calls to the Copilot API and returns pre-recorded responses
from YAML snapshot files. This avoids needing real authentication in CI.
Key constraint: Java's CapiProxy.java always sets GITHUB_ACTIONS=true
(line 104), which forces the replay proxy into read-only mode. You cannot
record snapshots by running Java tests — you must handcraft the YAML.
test/snapshots/ (e.g., system_message_sections)e.g., should_use_replaced_identity_section_in_response
test/snapshots/<category>/<snapshot_base_name>.yamlThe format is:
models:
- claude-sonnet-4.5
conversations:
- messages:
- role: system
content: ${system}
- role: user
content: <the exact prompt your test will send>
- role: assistant
content: <the response the proxy will return>
Rules:
${system} is a placeholder that matches ANY system message content${workdir} in tool arguments is substituted with the actual temp workDirtool_calls on assistant messages and role: tool for resultsPlace it in java/src/test/java/com/github/copilot/ with an IT suffix
(e.g., MyFeatureIT.java). The failsafe plugin picks up *IT.java files.
Template:
package com.github.copilot;
import static org.junit.jupiter.api.Assertions.*;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import com.github.copilot.generated.AssistantMessageEvent;
import com.github.copilot.rpc.MessageOptions;
import com.github.copilot.rpc.PermissionHandler;
import com.github.copilot.rpc.SessionConfig;
// ... other imports as needed
class MyFeatureIT {
private static E2ETestContext ctx;
@BeforeAll
static void setUp() throws Exception {
ctx = E2ETestContext.create();
}
@AfterAll
static void tearDown() throws Exception {
if (ctx != null) {
ctx.close();
}
}
@Test
void myTestMethod() throws Exception {
// 1. Configure the proxy to use your snapshot
ctx.configureForTest("my_category", "my_test_method");
// 2. Create a client (uses fake token + proxy automatically)
try (CopilotClient client = ctx.createClient()) {
// 3. Create a session with desired config
CopilotSession session = client.createSession(new SessionConfig()
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL))
.get(30, TimeUnit.SECONDS);
try {
// 4. Send the prompt (must match YAML exactly)
AssistantMessageEvent response = session
.sendAndWait(new MessageOptions().setPrompt("Your prompt here"), 60_000)
.get(90, TimeUnit.SECONDS);
// 5. Assert on the response
assertNotNull(response);
String content = response.getData().content();
assertTrue(content.contains("expected text"));
} finally {
session.close();
}
}
}
}
cd java
mvn spotless:apply
mvn failsafe:integration-test -Dit.test="MyFeatureIT#myTestMethod" -Denforcer.skip=true
Then run the full build to confirm no regressions:
mvn clean verify
| What | Where |
|------|-------|
| Test context (manages proxy, workDir, CLI) | java/src/test/java/com/github/copilot/E2ETestContext.java |
| Java proxy wrapper | java/src/test/java/com/github/copilot/CapiProxy.java |
| Replay proxy (TypeScript) | test/harness/replayingCapiProxy.ts |
| Proxy server entry point | test/harness/server.ts |
| Snapshot files | test/snapshots/<category>/<name>.yaml |
| Existing IT tests for reference | java/src/test/java/com/github/copilot/*IT.java |
${system} (wildcard)${workdir} pathsGITHUB_ACTIONS=true) it errors with "No cached response found"If your test involves tool use:
conversations:
# First exchange: model wants to call a tool
- messages:
- role: system
content: ${system}
- role: user
content: Read the file test.txt
- role: assistant
content: I'll read that file.
tool_calls:
- id: toolcall_0
type: function
function:
name: view
arguments: '{"path":"${workdir}/test.txt"}'
# Second exchange: after tool result is provided, model gives final answer
- messages:
- role: system
content: ${system}
- role: user
content: Read the file test.txt
- role: assistant
content: I'll read that file.
tool_calls:
- id: toolcall_0
type: function
function:
name: view
arguments: '{"path":"${workdir}/test.txt"}'
- role: tool
tool_call_id: toolcall_0
content: "1. Hello world!"
- role: assistant
content: The file test.txt contains "Hello world!"
Important: When the model calls tools like view, the CLI actually executes
them locally. The file must exist in the test's workDir. Create it in your test
before sending the prompt:
Files.writeString(ctx.getWorkDir().resolve("test.txt"), "Hello world!\n");
session.sendAndWait(new MessageOptions().setPrompt("...")) sends.
${system} — Always use ${system} for the system role contentunless testing a specific system message matching scenario.
view or otherbuilt-in tools, the CLI will actually execute those tools. Files must exist.
configureForTest, e.g., configureForTest("category", "my_method_name").
Do not rely on camelCase-to-snake_case conversion.
CapiProxy.java forces GITHUB_ACTIONS=true.Always handcraft snapshots or use the Node.js proxy directly for recording.
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
Use when implementing any feature or bugfix, before writing implementation code
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating quantitative trading strategies. Covers "beating ideas to death" methodology, parameter robustness testing, slippage modeling, bias prevention, and interpreting backtest results. Applicable when user asks about backtesting, strategy validation, robustness testing, avoiding overfitting, or systematic trading development.
Cloud laboratory platform for automated protein testing and validation. Use when designing proteins and needing experimental validation including binding assays, expression testing, thermostability measurements, enzyme activity assays, or protein sequence optimization. Also use for submitting experiments via API, tracking experiment status, downloading results, optimizing protein sequences for better expression using computational tools (NetSolP, SoluProt, SolubleMPNN, ESM), or managing protein design workflows with wet-lab validation.
This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.
Take github/new-java-e2e-test-yaml-and-test from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.