agentleFS
GitHubKnown publishergithub/copilot-sdk/rust/AGENTS.md

copilot-sdk / rust

AGENTS.md11k starsChanged 3 months agoMITView on GitHub

This directory contains the independent github-copilot-sdk crate. In standalone SDK workflows, paths and Cargo commands below are relative to this directory, and this crate's own lockfile and toolchain apply. When nested at src/sdk/rust, the runtime CLI consumes the same checked-out sources through the Bazel integration described under Development. The runtime's N-API architecture does not otherwise govern this crate. - Use the existing Error and ErrorKind in src/errors.rs. Extend that public error contract instead of adding parallel per-module error types or…

Trending

Steady talk.about the whole repository

Dec 2025: 0 mentionsJan 2026: 14 mentionsFeb 2026: 2 mentionsMar 2026: 2 mentionsApr 2026: 1 mentionMay 2026: 2 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 2 mentionsSep 2026: 1 mentionOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the github/copilot-sdk repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about github/copilot-sdk

The biggest 5 of 25 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 25

Talked about on GitHub, Bluesky and Hacker News (25 times).

On GitHub · 13

8 more on GitHub

On Bluesky · 11

6 more on Bluesky

On Hacker News · 1

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository6 other files it gives its agents.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

13 rules. About 0 are common, 3 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Use the existing Error and ErrorKind in src/errors.rs.

    line 14
  2. Distinctive:

    Treat exported types, builders, and trait signatures as a consumer-facing contract.

    line 17
  3. Distinctive:

    Document public APIs with rustdoc.

    line 20
  4. Very specific:

    Use the per-request traits in src/handler.rs, such as PermissionHandler with SessionConfig::with_permission_handler, and retain their …

    line 26
  5. Very specific:

    Prefer its per-hook methods.

    line 30
  6. Very specific:

    Do not edit src/generated/ by hand.

    line 47
  7. Very specific:

    Keep handwritten consumer-facing types in src/types.rs when the wire types cannot express the public API, rather than patching generated …

    line 56
  8. Very specific:

    Use this crate's rust-toolchain.toml, Cargo.toml, and rustfmt configuration, not the runtime workspace's.

    line 73
  9. Very specific:

    Do not restore a repository-wide COPILOT_SKIP_CLI_DOWNLOAD.

    line 93
  10. Very specific:

    Run it with COPILOT_SKIP_CLI_DOWNLOAD unset.

    line 100
  11. Very specific:

    Keep unit tests in external test-only modules: foo.rs declares #[cfg(test)] mod tests;, and its tests live in foo/tests.rs.

    line 103
  12. Very specific:

    Keep integration tests in tests/.

    line 107
  13. Distinctive:

    Default features bundle the CLI.

    line 111

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->

Rust SDK

This directory contains the independent github-copilot-sdk crate. In standalone SDK workflows, paths and Cargo commands below are relative to this directory, and this crate's own lockfile and toolchain apply. When nested at src/sdk/rust, the runtime CLI consumes the same checked-out sources through the Bazel integration described under Development. The runtime's N-API architecture does not otherwise govern this crate.

Public API and errors

  • Use the existing Error and ErrorKind in src/errors.rs. Extend that public error contract instead of adding parallel per-module error types or returning anyhow::Error from library APIs.
  • Treat exported types, builders, and trait signatures as a consumer-facing contract. Adding a required field to a public struct can break callers' struct literals; preserve compatibility with existing construction patterns.
  • Document public APIs with rustdoc. Keep cross-language parity notes in README.md, rather than repeating comparisons to other SDKs on individual symbols.

Extension points and session lifetime

  • Use the per-request traits in src/handler.rs, such as PermissionHandler with SessionConfig::with_permission_handler, and retain their declared Send + Sync + 'static contracts.
  • Implement SessionHooks in src/hooks.rs for lifecycle hooks. Prefer its per-hook methods; with_hooks enables hooks on the session.
  • Implement SystemMessageTransform in src/transforms.rs with section_ids and transform_section, and register it through with_system_message_transform.
  • Attach a ToolHandler to a Tool with with_handler, then register tools with with_tools. The derive feature exposes define_tool and schema_for for typed tool parameters. Use the current examples in src/tool.rs, not hand-built JSON wire payloads.
  • EventSubscription and LifecycleSubscription are streams; dropping a subscription unsubscribes. Session::cancellation_token returns a child token, so cancelling it must not cancel the parent session. Preserve these ownership and cancellation semantics when changing event dispatch.
  • ApproveAllHandler is suitable for tests that do not exercise permission or managed-settings behavior. It is not an override for managed approval.

Generated types

Do not edit src/generated/ by hand. The generator is ../scripts/codegen/rust.ts. From <SDK_ROOT>, regenerate with the SDK facade so the runtime layout selects checked-out schemas and the standalone layout selects its pinned release schemas:

npm run generate:rust

Keep handwritten consumer-facing types in src/types.rs when the wire types cannot express the public API, rather than patching generated output. Changes to release-derived CLI pins and schema inputs belong to the release process, not incidental SDK implementation work.

Development

In the runtime repository, prefer npm --prefix <SDK_ROOT> run test:rust; it refreshes the selected schemas and Rust projection and requests a current host CLI before running the tests. Direct Cargo commands bypass those prerequisites and the facade's environment applies only to its child process; it does not persist for later shell commands. The CLI consumes this crate through the same-checkout //src/sdk/rust:github-copilot-sdk-local-runtime Bazel target, with default features disabled. That local-runtime mode enables in-process transport without SDK-managed acquisition because the CLI supplies the adjacent runtime.node; bundled-cli takes precedence in all-feature builds.

Use this crate's rust-toolchain.toml, Cargo.toml, and rustfmt configuration, not the runtime workspace's. See README.md#development for Node and replay-harness prerequisites. Cargo restores Rust dependencies. The following direct Cargo commands are standalone SDK repository commands and use its published/bundled acquisition semantics:

cargo check --all-features
cargo test --features test-support
cargo clippy --all-targets --all-features -- -D warnings
cargo +nightly-2026-04-14 fmt --all -- --config-path .rustfmt.nightly.toml --check

For changes to the CLI's SDK consumer path, run the repository's Bazel tests from the runtime root:

pnpm bazel test //src/native/cli-runtime:cli-native-runtime_test //src/native/cli-runtime:runtime_sibling_resolution //src/native/cli-runtime:typed_sdk_call

Do not restore a repository-wide COPILOT_SKIP_CLI_DOWNLOAD. For focused same-checkout compilation from this directory, use:

cargo check --no-default-features --features local-runtime

Run it with COPILOT_SKIP_CLI_DOWNLOAD unset. Tests that start the runtime must also set COPILOT_CLI_PATH to the prepared same-checkout wrapper.

Keep unit tests in external test-only modules: foo.rs declares #[cfg(test)] mod tests;, and its tests live in foo/tests.rs. Crate roots such as lib.rs use a sibling tests.rs; descriptive module names keep their corresponding file names. Start each test-only file with #![cfg(test)]. Keep integration tests in tests/. Integration tests needing SDK test helpers use the test-support feature because the library is compiled without cfg(test).

Default features bundle the CLI; disabling them changes what must be provided externally. For transport-specific E2E settings, bundled-runtime checks, and the full platform matrix, follow the Rust SDK workflow. A local unit test run does not replace those checks.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.