# AGENTS.md
Guidance for coding agents working on this repository. Read `README.md` and
the crate docs in `src/lib.rs` for the format specification; they mirror
each other and must stay in sync.
## Project
`stringcue` is String Compressed Unicode Encoding: a space-efficient storage
encoding for strings, typically around an eighth smaller than UTF-8, at the
cost of robustness. It is storage-only — decoding depends on the whole blob,
so safe partial processing is out of scope by design. Blob integrity is the
caller's responsibility (e.g. an additional checksum).
## Hard constraints
- `no_std` with `extern crate alloc` (`src/lib.rs`). Use `core`/`alloc`
imports, never `std`.
- `#![forbid(unsafe_code)]` — never add `unsafe`.
- `missing_docs` and `missing_debug_implementations` are denied: every public
item needs a doc comment.
- MSRV is 1.83 (see `Cargo.toml`, the single source for version and metadata).
## Code style
- Doc comments (`///` and `//!`) only; no plain `//` comments.
- Docs carry the explanation. Doctest examples use ` ```no_run ` while the
functions are unimplemented; switch them to runnable examples once
implemented so they act as tests.
- The public API surface is exactly what `src/lib.rs` re-exports. Keep it
small; the crate is at 0.1.0, so treat signature changes as breaking.
- Stay concise and human-readable
- Do the usual derives (Clone, Copy, Default, etc.) where reasonable
- Errors are `#[non_exhaustive]` enums with a hand-written `Display` impl and
`core::error::Error` (never `std`, never an error-macro crate like
`thiserror`); they carry no fix-up promise for corrupted blobs —
re-encode the original strings instead of repairing a blob.
- Small unit tests live inside each file's `#[cfg(test)] mod tests`.
Follow the Rust guidelines when a module's tests outgrow it: move the
unit-test module to a sibling file included with `#[cfg(test)]
mod tests;` (e.g. `src/prefix.rs` → `src/prefix/tests.rs`), and put
black-box tests through the public API in the crate-root `tests/`
directory.
- Do not write tests for hardcoded values, e.g. do not unit test an explicitly programmed default value
by itself. Do test any actual algorithm and try to exercise all branches.
- Do not `unwrap()`, instead use `expect()` with a short message —
including tests and doctests.
## Current state and expected workflow
`src/encode.rs` and `src/decode.rs` are implemented and their tests run; keep
encoding and decoding aligned with the README spec. Before publishing a new
version to crates.io, run `cargo package --list` and check that IDE and CI
files stay out of the package (`Cargo.toml` excludes `.idea/` and
`.forgejo/`).
## Verification
- `cargo build` must stay warning-free under the crate-level lint config.
- `cargo test` must pass
## Process
- Work in small increments; one logical change per PR.
- Agents may create pull requests but never merge them.
- Keep PR descriptions short so they're appropriate for a squash commit, put further explanation and rationale in a comment on the PR