rust-regex-search-contracts
Skill0 starsChanged 39 days agoMITView on GitHub
Use when Rust regex refactors change match offsets, sliced searches invent word boundaries, a lexer skips invalid input, or multi-pattern searches choose the wrong token after switching engines.
In this repository66 other files it gives its agents.
- AGENTS.mdAGENTS.md
- postgres-locking-joinsSkill
- ai-bug-patternsSkill
- compressed-ndjson-boundariesSkill
- http-resume-integritySkill
- linux-io-latency-triageSkill
- macos-disk-space-recoverySkill
- minimal-sufficient-evidenceSkill
- modularize-large-filesSkill
- patch-reproducer-validitySkill
- prompt-cache-boundariesSkill
- proton-drive-selective-backupSkill
- transactional-outbox-deliverySkill
- conventional-commitsSkill
- git-advanced-mergingSkill
- git-bisect-forensicsSkill
- git-data-recoverySkill
- git-hooksSkill
- git-rerereSkill
- git-reset-mechanicsSkill
- git-revisions-syntaxSkill
- git-rewriting-historySkill
- git-submodulesSkill
- git-worktreesSkill
- github-ssh-keysSkill
- npm-publish-ci-pitfallsSkill
- sapling-stacked-pr-workflowSkill
- go-concurrency-patternsSkill
- go-data-idiomsSkill
- go-error-handlingSkill
- go-interfaces-embeddingSkill
- go-pprof-profilingSkill
- marketing-funnel-diagnosisSkill
- marketing-geo-experimentsSkill
- marketing-incrementalitySkill
- marketing-positioning-testsSkill
- python-descriptors-mroSkill
- python-logging-cookbookSkill
- python-scaling-regression-testsSkill
- python-unicode-gotchasSkill
- rust-compile-time-invariantsSkill
- rust-deterministic-concurrency-testsSkill
- rust-error-identity-boundariesSkill
- rust-runtime-bug-classesSkill
- rust-tokio-actor-deliverySkill
- rust-tokio-cancellation-safetySkill
- sales-discovery-qualificationSkill
- sales-mutual-action-plansSkill
- sales-pipeline-forecast-calibrationSkill
- sales-value-negotiationSkill
- ai-triage-evaluationSkill
- container-image-patchingSkill
- dependency-artifact-integritySkill
- dnssec-sentinel-diagnosticsSkill
- iam-policy-change-replaySkill
- rbvm-applicabilitySkill
- rbvm-asset-evidenceSkill
- rbvm-guarded-remediationSkill
- rbvm-priority-decisionsSkill
- rbvm-risk-exceptionsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 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.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Search configuration is part of correctness.
- Distinctive: line 20
Prefer the meta engine unless measured requirements justify owning lower-level limitations.
- Distinctive: line 40
Before replacing an engine, compare pattern IDs, spans, captures, empty matches, Unicode cases, and errors, not just match counts.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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.
Files
Rust Regex Search Contracts
Search configuration is part of correctness. A faster engine is interchangeable only when its match policy, boundary context, offsets, and failure behavior match the caller's contract.
Choose the contract first
| Need | Construct | Trap |
| Boolean existence | meta::Regex::is_match | Computing captures adds unnecessary work |
| Search a region | Input::new(full).span(start..end) | Slicing changes boundary context and rebases offsets |
| Match at a lexer cursor | .anchored(Anchored::Yes) | Unanchored search silently skips unmatched bytes |
| Token identity plus span | meta::Regex::new_many | Pattern order breaks equal-start ties; this is not longest-token selection |
| Specialized engine | Fallible search plus explicit fallback | MatchError is indeterminate, not “no match” |
Prefer the meta engine unless measured requirements justify owning lower-level limitations. It composes engines and fallbacks; choosing a standalone DFA also transfers unsupported-input handling to you.
Preserve context
With regex-automata = "=0.4.13":
use regex_automata::{meta::Regex, Anchored, Input};
let re = Regex::new(r"\bcat\b")?;
let hay = "bobcat!";
assert!(re.is_match(&hay[3..6])); // Wrong context: invents a word.
assert!(!re.is_match(Input::new(hay).span(3..6)));
let token = Regex::new(r"[a-z]+")?;
let input = Input::new("!cat").span(0..4).anchored(Anchored::Yes);
assert!(token.find(input).is_none()); // Reject the gap; don't skip '!'.Anchored::Yes refers to the search start. Default ^ refers to the haystack start; multiline mode changes its meaning again. Validate input ranges before searching. Keep returned offsets in the original byte coordinate system.
Before replacing an engine, compare pattern IDs, spans, captures, empty matches, Unicode cases, and errors, not just match counts. The fixture provides six failure/remedy cases; provenance records runtime limits.
Pitfalls
- Reordering alternatives or patterns changes leftmost-first results. Longest-token lexing needs its own explicit selection policy.
earliest(true)may change the chosen match; it is not a semantics-preserving speed switch.MatchKind::Allis not a drop-in “find every occurrence” mode for ordinary unanchored iteration.- Handwritten cursor loops can stall on empty matches; use the engine's iterator when its non-overlapping semantics fit.
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
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.

