원클릭으로
libmagic-rs-patterns
Project-specific conventions for libmagic-rs (commit style, error patterns, testing layout, tooling)
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Project-specific conventions for libmagic-rs (commit style, error patterns, testing layout, tooling)
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Security review for Rust systems code. Covers memory safety, buffer handling, unsafe code, input validation, resource exhaustion, and supply chain security.
Rust library API design patterns including builder pattern, error handling, trait design, type safety, and CLI design with clap.
Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.
Enforces test-driven development for Rust. Write tests first with cargo test/nextest, implement to pass, refactor, verify >85% coverage with cargo llvm-cov.
Comprehensive verification for Rust projects. Runs cargo check, clippy, fmt, tests, coverage, and security audit in sequence.
| name | libmagic-rs-patterns |
| description | Project-specific conventions for libmagic-rs (commit style, error patterns, testing layout, tooling) |
| source | AGENTS.md + GOTCHAS.md |
Authoritative architectural state lives in AGENTS.md and GOTCHAS.md. This skill captures only the stable patterns that don't drift -- commit conventions, error/testing style, and tooling. When in doubt, AGENTS.md wins.
Conventional commits required. Types in use:
feat: -- new featuresfix: -- bug fixesrefactor: -- restructuring without behavior changechore: (incl. chore(deps):, chore(ci):) -- maintenancedocs: -- documentationtest: -- test additions or changesperf:, ci: -- as relevantEvery commit must be signed off with git commit -s (DCO). The project's
documented best practice is git commit -sS -m "..." (DCO + GPG together).
PR references in messages use (#N) suffix format.
See AGENTS.md sections "Architecture Patterns" and "Module Organization"
for the authoritative module tree. The parser splits across
parser/{ast,grammar/,types,codegen,...} and the evaluator splits across
evaluator/{engine/,types/,operators/,offset/,strength,...} -- both are
directory modules, not flat files.
Magic File -> Parser -> AST -> Evaluator -> Match Results -> Output Formatter
^
Target File -> Memory Mapper -> File Buffer
MagicDatabase -- public entry point (load rules, evaluate buffers/files)MagicRule -- a single rule (#[non_exhaustive]; do not literal-construct
outside the crate)OffsetSpec, TypeKind, Operator, Value -- AST nodes in
src/parser/ast.rs; variant lists evolve, check the sourceLibmagicError / ParseError / EvaluationError -- error hierarchy in
src/error.rsStrict workspace lints in Cargo.toml [workspace.lints]:
unsafe_code = "forbid" -- enforced project-wide via workspace lints, not
via a #![forbid(unsafe_code)] attributewarnings = "deny" -- zero-warnings policyunwrap_used = "deny", expect_used = "deny" in library codepanic is also denied where possible; see Cargo.toml for the exception
note (it would be forbidden but breaks clap)pedantic, nursery, cargo groups enabledindexing_slicing, arithmetic_side_effects,
string_slicethiserror-based enums with named constructor methods:
#[derive(Debug, thiserror::Error)]
pub enum ParseError {
#[error("Invalid syntax at line {line}: {message}")]
InvalidSyntax { line: usize, message: String },
}
impl ParseError {
#[must_use]
pub fn invalid_syntax(line: usize, message: impl Into<String>) -> Self {
Self::InvalidSyntax { line, message: message.into() }
}
}
impl Into<String> for ergonomics#[must_use]See GOTCHAS S1.1 for the build-script boundary: src/error.rs is shared
with build.rs and cannot reference lib-only types.
#[cfg(test)] mod tests alongside source filestests/*.rstests/compatibility_tests.rs against the
upstream file test suitetests/property_tests.rs using proptestbenches/*.rs using criterioninsta.unwrap() and .expect() are denied in library code but acceptable
inside #[cfg(test)] modules and tests/*.rs (see
.claude/hookify.warn-panic-in-lib.md).
mise exec --)mise exec -- cargo nextest run --workspace --no-fail-fast
mise exec -- just ci-check # full pre-commit parity
mise exec -- just coverage # coverage report
mise exec -- just test-compatibility
Build logic extracted into a testable library module so build-time failures have proper test coverage:
src/build_helpers.rs -- testable parsing and code generationbuild.rs -- minimal entry point that delegates to build_helpersSee AGENTS.md "Testing Build Scripts" for the rationale.
mdformat, shellcheck, actionlint,
cargo-machete, cargo-audit)docs/.github/workflows/release.yml is
auto-generated -- never edit by hand)Cargo.toml rust-version (don't pin from memory; check
the file)style_edition = "2024"Debug, Clone, Serialize, Deserialize, PartialEq
where shape allows (Value does not derive Eq because it holds f64
-- see GOTCHAS S2.3)cargo test --doc#[non_exhaustive] on public enums and many structs -- do not literal-
construct from outside the crateThe hookify warn rules (.claude/hookify.warn-*.md) cover the day-to-day
discipline. Headline rules:
.get() for buffer access, never direct indexingstrip_prefix() / strip_suffix() instead of &str[n..] (avoids
UTF-8 boundary panics)unwrap() / expect() / panic! in library code (test code OK)EvaluationConfig::timeout_ms)