copilot-instructions rust-code-organization.instructions.md

Coding instructions for organizing Rust projects, including matching source and test folders, grouping related code, and managing build output.

In plain words
What is it for?
Use them when adding or reorganizing Rust modules, writing matching tests, documenting code, or cleaning build artifacts before validation or release.
Why use it?
They give an AI coding assistant consistent rules for where Rust code belongs and help prevent stale or oversized files in target/, Rust's build-output directory.

Instructions file for GitHub Copilot

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/thiagoguislotti/copilot-instructions/rust-code-organization
Clone the repo
git clone --depth 1 https://github.com/ThiagoGuislotti/copilot-instructions

Made for: GitHub Copilot.

Per session 3,050 This file is loaded in full into every session.
When invoked 3,050 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.03050 $0.03050
Opus 5 $0.01525 $0.01525
Sonnet 5 $0.00610 $0.00610
Haiku 4.5 $0.00305 $0.00305

Measured 2d ago against content hash 79ce169a9548, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

copilot-instructions rust-code-organization.instructions.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/instructions/rust-code-organization.instructions.md · 471 lines

How it starts

The opening of the file, as written. The whole thing — 471 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Rust Code Organization

Core Principles

Mirror src/ structure in tests/ exactly; production code in src/, tests in tests/; no #[cfg(test)] blocks in production; follow Rust module conventions; group related types by functionality - multiple structs/traits per file is idiomatic Rust.

Rule: Test file structure MUST mirror source file structure. Rule: Files are organized by module/functionality, NOT by type. A file named config.rs can contain LinearConfig, BsgsConfig, and related types. Rule: Only split into separate files when a file exceeds ~300-500 lines or when types have distinct responsibilities. Rule: target/ is disposable build output and must be kept lean; retain only artifacts needed for the active workspace, target triple, and profile.

Build Artifact Hygiene

  • Never treat target/ as durable project state; do not rely on stale artifacts across task changes, branch switches, toolchain updates, or release/debug profile changes.
  • Clean stale Rust outputs proactively when target/ grows abnormally, when switching workspace context, or before handing work off for validation/release.
  • Prefer scoped cleanup first when possible: cargo clean -p <crate>, cargo clean --profile <profile>, or pruning obsolete target/<triple>/<profile> folders that are no longer part of the active build.
  • Use full cargo clean when the directory is bloated, inconsistent, or shared across incompatible builds/features.
  • When multiple Rust repositories are active on the same machine, prefer a repository-specific CARGO_TARGET_DIR to avoid cross-project accumulation and accidental reuse.
  • Never commit target/; keep only the outputs required by the current build/test session.

Documentation Standards

Doc comments must be complete and self-explanatory; describe purpose, inputs, outputs, errors, side effects, and invariants; avoid restating identifiers.

  • Provide a clear summary sentence for every public item; describe behavior and side effects.
  • Document arguments, return values, and error conditions for public functions; include explicit Panics, Errors, and Safety sections when relevant.
  • Enable the missing_docs lint with crate-level attribute #![warn(missing_docs)] in the crate root; fix warnings instead of suppressing.

Read the full file on GitHub · 471 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 471 lines · 3,050 tokens per session scan A 79ce169a9548

Subscribe to this mod's changes

copilot-instructions rust-code-organization.instructions.md is an instructions file published in the GitHub repository ThiagoGuislotti/copilot-instructions (2 stars, last pushed 2mo ago), licensed MIT. It adds 3,050 tokens to every session, about $0.0153 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories

spec-kit AGENTS.md

AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.

github/spec-kit · 7,104 tokens

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 6,785 tokens

codex AGENTS.md

AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.

openai/codex · 5,182 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,345 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).

microsoft/vscode · 5,001 tokens

next.js AGENTS.md

Instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,296 tokens