Skip to navigation

Cargo Profile Boundaries: Keep Debug and Release Behavior Aligned

In short: Find which Cargo profile settings affect diagnostics, optimization, or runtime behavior before Claude Code edits them.

Published 20 min read
On this page

Direct answer

Cargo ships four built-in profiles named dev, release, test, and bench, and it selects one from the command unless you override it. The useful boundary for editing them is purpose: some profile settings change diagnostics you see, some change optimization the compiler applies, and a smaller set changes observable program behavior. Treat the first two as build metadata and treat the third as a behavior change that needs its own review. The concrete win is a set of profiles where debug and release differ only where you intended, so a bug that appears in one and not the other points at a real difference. The concrete loss is that release mode is not automatically faster for every workload, and an optimization flag that helps one crate can be irrelevant or counterproductive for another, so profile edits are not proof of a speedup.

Ask Claude Code to classify each profile setting by purpose before changing it. A release build that silently turns off overflow checks or changes debug information is a behavior change hiding inside a speed edit, and that is the class of change this post is about catching.

Why a profile edit is not a cosmetic edit

Three failure modes come from treating profile settings as free knobs. A team chasing a faster build turns off debug assertions and loses a check that was catching a real invariant violation in development. A release build disables overflow checks to shave a benchmark, and an arithmetic bug that was caught in dev now wraps silently in production. Debug information settings change what a crash report or a profiler can tell you, and a change made for build speed removes the exact symbol a postmortem needed.

None of these are compiler defects. They are the predictable cost of editing settings that look like performance tuning but change what the program does or what you can observe about it. The cost lands later: a harder-to-diagnose crash, a production arithmetic bug that did not exist in dev, or a profiling session with no useful symbols.

There is a revert advantage in profile work. Profile settings live in Cargo.toml under [profile.*] tables, so a change is a small, revertible diff with no source changes. That makes profile review a reasonable Claude Code task, as long as the classification step happens before the edit and the diff is judged against intent rather than against a benchmark number.

Evidence and its limits

Official, F017: The Cargo Book documents four built-in profiles named dev, release, test, and bench, and documents that a profile is selected from the command unless overridden. The cargo build command reference shows how --release and related flags map to a profile. Custom profiles and package-specific overrides can add more cases beyond these four, so a project can have more moving parts than the built-in list suggests.

Official, F018 support: The same profiles reference documents individual settings, including optimization level, debug information, and overflow checks. The manifest format reference documents where profile tables live.

Official, workspaces: The workspaces reference documents that profiles are defined at the workspace root and that package-specific overrides are possible. A profile change in a member crate does not behave the same as one at the workspace root, which is why the workspace section below matters.

Official, agent loop: Claude Code best practices recommends giving the agent a check that returns pass or fail. For a profile change the check is a build of the affected profile plus, where behavior could change, a test run under that profile.

Derived, F018: A review method that separates diagnostic and optimization settings from options that can change observable program behavior is an editorial classification built on the official profiles documentation. It is a review aid, not a vendor guarantee, and each setting should be confirmed against the current profile reference.

No benchmark result, compile-time number, or runtime speedup is reported in this post, because none was measured. A profile change is not presented as evidence of a speed improvement.

Built-in Cargo profiles

The four built-in profiles cover the common build modes. dev is the default for cargo build, release is selected by cargo build --release, test applies when running tests, and bench applies to benchmarks. Each has documented defaults, and any of them can be overridden in Cargo.toml.

Profile Selected by Typical intent Overridable
dev cargo build Fast iteration, full diagnostics Yes, [profile.dev]
release cargo build --release Optimized output Yes, [profile.release]
test cargo test Tests under development settings Yes, [profile.test]
bench cargo bench Benchmark builds Yes, [profile.bench]

Read the table as a selection map rather than a speed ranking. The profile chosen is a function of the command, and the settings under each profile are defaults you can change. Custom profiles are also possible, which means a project can define its own named builds beyond these four.

The classification that matters for review is not which profile but which kind of setting lives under it. That is the boundary the rest of the post is about.

Read profile overrides

A [profile.*] table in Cargo.toml overrides defaults for that profile. Settings include optimization level, debug information, whether debug assertions are on, and whether overflow checks are on. The profiles reference documents each setting and its default per profile.

bash
[profile.release]
opt-level = 3
debug = true
overflow-checks = true

The example above is a release profile that keeps debug information and overflow checks on. It is an example of the shape, not a recommendation for every project. What makes it reviewable is that each line has a stated purpose: opt-level is an optimization setting, debug is a diagnostics setting, and overflow-checks is a behavior setting.

Package-specific overrides narrow a setting to one crate in the graph using [profile.*.package."name"]. The workspaces reference documents that profiles are defined at the workspace root, so a profile that seems to be a per-crate edit can actually be a workspace-wide one. Confirm where a profile table lives before reasoning about its scope.

Override form Scope Review question
[profile.release] at workspace root All crates in the build Does this apply to more than the crate I meant?
[profile.release.package."my-crate"] One crate Is this crate the right unit for the change?
[profile.dev] Development builds Does this change what developers observe day to day?
Custom [profile.something] Selected explicitly Who selects this profile and when?

Read the table as a scope map. The most common surprise is a setting intended for one crate that lands on the whole build because it was written at the workspace root.

Separate diagnostics and optimization

Two large families of profile settings do not change what your program computes. Diagnostic settings control what information is available about the program: debug information, symbols, and similar. Optimization settings control how the compiler produces the output: optimization level and related choices. Both change the build artifact, but neither is primarily a statement about program behavior.

Setting family Examples What it changes What it does not change
Diagnostics debug, symbol settings Information available in a debugger or profiler The computed result
Optimization opt-level How output is produced The computed result, for well-defined programs

The boundary is useful because it tells you what kind of review a change needs. A diagnostics change should be judged by whether the information you need is still available when something breaks. An optimization change should be judged by whether the build goal is met, and any claim of improvement should come from a measurement you actually ran, not from the setting itself.

The reason this post does not assert any speedup is that optimization effects are workload-specific. The same opt-level can matter a great deal for one crate and be irrelevant for another, and the reference does not promise a uniform improvement. Treating a profile edit as proof of speed is the claim to avoid.

Identify behavior-changing settings

A smaller set of profile settings can change observable program behavior. The clearest documented example is overflow checks: when enabled, integer overflow panics, and when disabled, it wraps. A program that relies on one behavior or the other will behave differently depending on this setting, across profiles.

Setting Behavior impact Review caution
overflow-checks Panics on overflow when on, wraps when off A dev/prod difference here is a real behavior difference
Debug assertions Extra invariant checks when on Turning them off in release removes a dev-only guard
Anything feeding #[cfg] logic Changes which code compiles Confirm the compiled behavior, not just the flag

Read the table as the short list that deserves the most scrutiny. A profile whose only difference from dev is optimization level produces the same computation at a different speed. A profile that also differs on overflow checks or debug assertions produces a program that can behave differently, and that difference is exactly what the phrase “it only happens in release” describes.

The rule this post suggests is not that these settings are forbidden. It is that a change to them is a behavior change and should be reviewed as one: named in the commit, justified in a sentence, and, where feasible, covered by a test that would notice the difference.

Compare dev and release intent

The most common profile question is why a bug appears in release and not in dev, or the reverse. The answer is usually one of two things: a behavior-changing setting differs between the profiles, or an optimization exposes a latent assumption in the code that dev’s less-optimized build did not surface. Both are worth distinguishing before touching a profile.

Difference between dev and release Likely category What to check
Only optimization level differs Optimization Look for latent assumptions, not the profile itself
Overflow checks differ Behavior Confirm arithmetic assumptions in the code
Debug assertions differ Behavior Confirm which invariants are dev-only
Debug information differs Diagnostics Confirm crash reports still have usable symbols

Reading the table top down, only the first row is genuinely an optimization story. The middle two are behavior differences that a profile edit introduced or revealed. The last is a diagnostics difference that affects what you can learn after a failure.

The practical method is to diff the two profiles’ effective settings rather than to guess. The reference documents each setting and its default per profile, so the diff is obtainable from the documentation and your Cargo.toml without running anything. That diff is the artifact to bring to the review of a “works in dev, fails in release” report.

Review workspace inheritance

Profiles are defined at the workspace root, which means a profile edit in a workspace is a workspace-wide edit unless it is scoped to a package. This is the property most often missed when a team assumes a profile change is local to the crate they were working on.

Where the profile lives Effective scope Common surprise
Workspace root [profile.release] Every crate in the build Change meant for one crate hits all of them
Package override under a profile One named crate Assumed workspace-wide when it was not
Member manifest [profile.*] Ignored or an error depending on setup Expecting a member to override independently

Read the table as the workspace boundary for profiles. The Cargo workspace inheritance guide covers a different mechanism: sharing manifest metadata such as version and license fields through workspace.package. Profile tables and inherited package metadata are separate systems, and a change to one does not imply anything about the other.

The review implication is that a workspace profile change needs a wider build and test pass than a single-crate change. A setting that seems harmless for the crate you edited can change a sibling’s behavior through the shared profile, and the only way to catch that is to build and test the affected set rather than one crate.

Document profile decisions

Profiles accumulate. A setting added for one benchmark or one incident stays in the file long after the reason is forgotten. The remedy is a short record next to each non-default override: what the setting is, why it was changed, and what would tell you to remove it.

Override Purpose Review trigger to revisit
debug = true in release Keep symbols for production crash reports If crash reporting changes or is removed
overflow-checks = true in release Keep arithmetic safety consistent with dev If a measured hot path needs it off, with a test
opt-level tuned Build or runtime goal for a specific crate Re-measure when the workload changes

The record turns a profile from a pile of inherited knobs into a set of decisions a reviewer can evaluate. It also makes the honest loss visible: a profile that is documented is one you can reason about, but it still does not prove anything about performance without a measurement.

The concrete win, loss, and implication

The concrete win is alignment between dev and release. When the only differences between profiles are the ones you chose deliberately, a bug that appears in one profile and not the other points at a real difference you can name. That shortens the path from “it only happens in release” to a specific setting and a specific code assumption.

The concrete loss is that profile edits do not buy a guaranteed speedup. Release mode is not automatically faster for every workload, and an optimization flag that helps one crate can do nothing for another. Any claim that a profile change made something faster needs a measurement behind it, and this post deliberately provides none.

The practical implication is that profile settings deserve review by purpose, not by vibes. Teams that classify each setting as diagnostic, optimization, or behavior change, and that treat the third category as a real behavior change, spend less time chasing profile-induced bugs. Teams that treat every release setting as a free speed knob keep discovering that overflow checks and debug assertions were doing work.

Profile settings are one build boundary among several this batch covers. On the same crate, the Cargo feature unification guide covers how features combine across selected packages to expose optional APIs, and the Cargo build scripts guide covers generated artifacts and rerun conditions. Profiles decide how code is built; features decide what is built; build scripts decide what is generated first. Keeping the three straight is most of the work.

Workspace scoping connects to the Cargo workspace inheritance guide, which covers sharing manifest metadata while keeping crate identity local. Version and graph selection in other ecosystems appear in Go Module Graph Pruning, which covers minimal version selection and indirect requirements, and Gradle Constraints vs Dependencies, which covers influencing a version without adding a graph edge.

CMake presets cover the same reproducible-build-input idea for C++ projects: CMake Presets covers giving an agent reproducible configure inputs. Conan CMakeDeps covers keeping consumer targets stable across generated CMake integration.

Review and verification habits around profile edits

Profile changes are quiet, which makes verification habits relevant. Before calling a profile edit done, ask what Claude Code verification requires, and prevent false success from passing tests when the check is a green build that ran under a different profile than the one you changed. A build under dev says little about a release-only behavior difference.

The cost of building and testing under each affected profile connects to Claude Code cost per verified change. A profile diff is a cheap check that earns its place on every profile edit. When a profile tweak turns into a manifest-wide reformat, that is the pattern the Claude Code overengineering guide warns about.

On the review side, Claude Code code review covers what happens when faster generation outpaces the review that has to accept it. A behavior-changing profile edit is exactly the kind of small diff that deserves a slow look.

Evidence map showing Cargo's four built-in profiles and that overrides should be reviewed by purpose rather than copied between profiles.
Editorial evidence map based on F017 and F018. Cargo ships dev, release, test, and bench profiles; overrides deserve review by purpose. Labels are the post author’s.

Checklist before you change a profile

Run this list before approving a profile change. Each row is a pass condition.

Check Pass condition If it fails
Setting classified Each changed setting labeled diagnostic, optimization, or behavior Classify before editing
Scope confirmed Location of the profile table matches intended scope Check workspace root vs package override
Behavior settings named Any overflow or assertion change is called out in the commit Rewrite the commit to name the behavior change
Affected profile built The build uses the profile you changed Build under the target profile
Tests run under that profile Behavior-changing edits have a test under that profile Add a test that would notice the difference
No benchmark claim without data Any speed claim cites a measurement you ran Remove the claim or run the measurement
Decision recorded Non-default overrides have a stated purpose Add a one-line reason beside each
Workflow from classifying profile settings by purpose through scoping the override, building under the target profile, and running tests where behavior could change.
Editorial workflow based on F017 and F018. The sequence describes a reviewable routine; it is not an official Cargo command sequence.

Working with Claude Code on a profile change

Give the agent three inputs: the setting you want to change and why, the profile and scope, and the definition of done. Ask for a classification of each affected setting by purpose, a diff of the effective profile settings, and a build plus test under the target profile where behavior could change.

Reviewing the agent’s classification is the reviewer’s job. The agent can read the profiles documentation and your manifest, but deciding whether a behavior-changing setting is acceptable in release is a risk decision that needs your input. The Claude Code verification guide covers the review questions: what changed, what proves it, and what was not checked.

Tradeoff between aligned dev and release profiles you can reason about and the measurement work required before claiming any speedup.
Editorial tradeoff diagram based on F017 and F018. Aligned profiles make profile-specific bugs nameable; the trade is that speed claims still require measurement.

Data gap and future update

No benchmark, compile-time, or runtime measurement is reported in this post, because none was measured. The official profiles documentation describes settings and defaults; it does not promise a uniform speed improvement for any workload, and this post does not claim one. A future update quantifying the effect of a specific setting on a specific crate would need a measurement pass with a fixed toolchain and workload.

Custom profiles and package-specific overrides can add cases beyond the four built-in profiles in F017. The exact behavior of a given override in a given Cargo version should be confirmed against the current profiles reference, since this post does not enumerate version-specific behavior.

The interaction between profiles and the resolver or feature selection is out of scope. Features decide what is built and are covered in the Cargo feature unification guide; profiles decide how what is built is compiled.

One AI API Key option for OpenAI-format agents

Claude Code uses an Anthropic-format route, so the One AI free model IDs are not a Claude Code model source. The packet records Claude IDs as unavailable on 2026-11-27.

OpenAI-format agents have a separate route: One AI API Key offers https://api.oneaiapikey.com/v1, one key, and 46 live free IDs. It is a different client and request format, not a workaround for Claude Code authentication. Check the free model list and eligibility notes before choosing an agent route, or read the quickstart for the request shape.

FAQ

Does --release always make my program faster?

This post makes no such claim, and you should not assume it. Release mode applies optimization settings, but the effect is workload-specific, and the profiles documentation does not promise a uniform improvement. Any speed claim needs a measurement you actually ran on your workload.

Which profile settings change program behavior?

The clearest documented example is overflow checks: enabled, integer overflow panics; disabled, it wraps. Debug assertions are another, adding checks that are present when on and absent when off. A dev/release difference on these settings is a real behavior difference, not just a speed difference.

Where do profile settings live in a workspace?

Profiles are defined at the workspace root, so a [profile.*] table there applies across the build. Package-specific overrides narrow a setting to one crate. Confirm where a profile table lives before assuming its scope, because a change meant for one crate can land on all of them.

Can I copy release settings into dev to debug a release-only bug?

You can, but do it deliberately and treat it as a temporary reproduction step, not a permanent alignment. Copying behavior-changing settings masks the difference you are trying to study. Diff the effective settings first so you know which difference you are reproducing.

What proves a profile change is safe?

That the affected profile builds, that tests run under that profile pass, and that any behavior-changing setting is named and justified in the diff. A build under dev does not verify a release profile change. A speed claim additionally needs a measurement.

This post is one of six language and build-system guides written together. The Rust side continues with Cargo Feature Unification, Cargo Build Scripts, and Cargo Workspace Inheritance. The Go side is covered by Go Module Compatibility, Go Workspace Boundaries, and Go Module Graph Pruning.

JVM and .NET posts cover version and variant selection: Gradle Constraints vs Dependencies, Gradle Capability Conflicts, Gradle Variant Attributes, Maven Optional Dependencies, and NuGet Central Package Management covers cross-project version centralization, and .NET Multi-Targeting covers separating framework dependencies.

Generated-code and framework boundaries appear in C# Source Generators, OpenAPI Generator Customization, GraphQL Code Generator Client Presets, Django Deprecation Runway, Rails Upgrade Sequence, and Angular Update Guide.

More from this batch

More Claude Code troubleshooting

Sources

Control checklist covering setting classification, scope confirmation, building under the target profile, and naming behavior changes.
Editorial control checklist derived from F017 and F018. Passing the checklist shows the profile change was reviewed honestly; it does not prove any performance improvement.
Verdict that reviewing profile settings by purpose keeps dev and release behavior aligned and makes profile-specific bugs nameable.
Editorial verdict based on F017 and F018. Profiles are reviewed by purpose; a behavior-changing setting is a behavior change, and speed claims still need measurement.
More in Blog

Try it

One API key for GPT, Grok, DeepSeek, Kimi, GLM, MiniMax, Qwen, Step, Beam, Nemotron, ERNIE, Hunyuan, Gemma, Laguna, LFM, LongCat, Llama, Solar, Jais, Mistral, K2 and Roleplay.

One AI API Key speaks the OpenAI and Anthropic formats, so you change the base URL and the key, not your code. Credit packs start at $10, and every model has a published per-token rate.

New accounts$10 credit on sign-up
Claim $10 credit →