MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

GitHub Copilot SDK Java Instructions

GitHub Copilot SDK Java Instructions是一款code方向的AI技能,核心价值是This file provides guidance on building Java applications using GitHub Copilot SDK for Java,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

This file provides guidance on building Java applications using GitHub Copilot SDK for Java.

Last verified on: 2026-05-30
mkdir -p ./skills/copilot-sdk-java && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/copilot-sdk-java/SKILL.md -o ./skills/copilot-sdk-java/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

Core Principles


- The SDK is in public preview and may have breaking changes

- Requires Java 17 or later for baseline SDK usage. Some examples use newer JDK features and therefore require JDK 21 or later (for example, virtual threads via `Executors.newVirtualThreadPerTaskExecutor()` and `switch` pattern matching). **Java 25 or later highly recommended**.

- Requires GitHub Copilot CLI installed and in PATH

- Uses `CompletableFuture` for all async operations

- Implements `AutoCloseable` for resource cleanup (try-with-resources)

- Getters on configuration classes return `Optional<T>` (or `OptionalInt`/`OptionalDouble`) to distinguish "not set" from explicit values; setters accept raw types and return `this` for chaining. Use the `clear` methods to unset values if needed.


Installation


Maven


xml
<dependency>
    <groupId>com.github</groupId>
    <artifactId>copilot-sdk-java</artifactId>
    <version>${copilot-sdk-java.version}</version>
</dependency>

Gradle


groovy
implementation "com.github:copilot-sdk-java:${copilotSdkJavaVersion}"

Client Initialization


Basic Client Setup


java
try (var client = new CopilotClient()) {
    client.start().get();
    // Use client...
}

Virtual Threads (JDK 25+)


Virtual threads were introduced in JDK 21, but significant performance bugs were not fixed until JDK 25, making JDK 25 the minimum recommended version for production use of virtual threads. On JDK 25+, use a virtual-thread executor for significantly better scalability. The SDK's async operations will run on virtual threads instead of the default `ForkJoinPool`:


java
var options = new CopilotClientOptions()
    .setExecutor(Executors.newVirtualThreadPerTaskExecutor());

try (var client = new CopilotClient(options)) {
    client.start().get();
    // Use client...
}

Client Configuration Options


When creating a CopilotClient, use `CopilotClientOptions`:


- `cliPath` - Path to CLI executable (default: "copilot" from PATH)

- `cliArgs` - Extra arguments prepended before SDK-managed flags

- `cliUrl` - URL of existing CLI server (e.g., "localhost:8080"). When provided, client won't spawn a process

- `port` - Server port (default: 0 for random, only when `useStdio` is false)

- `useStdio` - Use stdio transport instead of TCP (default: true)

- `logLevel` - Log level: "error", "warn", "info", "debug", "trace" (default: "info")

- `autoStart` - Auto-start server on first request (default: true)

- `autoRestart` - Auto-restart on crash (default: true)

- `cwd` - Working directory for the CLI process

- `environment` - Environment variables for the CLI process

- `gitHubToken` - GitHub token for authentication

- `useLoggedInUser` - Use logged-in `gh` CLI auth (default: true unless token provided)

- `onListModels` - Custom model list handler for BYOK scenarios

- `remote` - Enable Mission Control / cloud session integration (default: false)

- `telemetry` - `TelemetryConfig` for OpenTelemetry export (since 1.2.0)

- `sessionIdleTimeoutSeconds` - Idle timeout before session auto-closes (since 1.3.0)

- `executor` - Custom `Executor` for async operations (default: ForkJoinPool)

- `tcpConnectionToken` - Security token for TCP transport authentication


java
var options = new CopilotClientOptions()
    .setCliPath("/path/to/copilot")
    .setLogLevel("debug")
    .setAutoStart(true)
    .setAutoRestart(true)
    .setGitHubToken(System.getenv("GITHUB_TOKEN"));

try (var client = new CopilotClient(options)) {
    client.start().get();
    // Use client...
}

Manual Server Control


For explicit control:

java
var client = new CopilotClient(new CopilotClientOptions().setAutoStart(false));
client.start().get();
// Use client...
client.stop().get();

Use `forceStop()` when `stop()` takes too long.


Session Management


Creating Sessions


Use `SessionConfig` for configuration. The permission handler is **required**:


java
var session = client.createSession(new SessionConfig()
    .setM

🎯 Best For

  • UI designers
  • Product designers
  • Claude users
  • GitHub Copilot users
  • Software engineers

💡 Use Cases

  • Generating component mockups
  • Creating design system tokens
  • Code quality improvement
  • Best practice enforcement

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply GitHub Copilot SDK Java Instructions to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Does this work with Figma?

Some design skills integrate with Figma plugins. Check the Works With section for supported tools.

Is GitHub Copilot SDK Java Instructions compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for GitHub Copilot SDK Java Instructions?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install GitHub Copilot SDK Java Instructions?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/copilot-sdk-java/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping usability testing

AI-generated designs should be validated with real users before development.

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills