# ryo-pattern
[](https://crates.io/crates/ryo-pattern)
[](https://docs.rs/ryo-pattern)
[](#license)
> **Status:** stable. Part of the [ryo](https://github.com/ynishi/ryo-rs) workspace —
> AST-centric Rust programming for AI agents.
RyoPattern — declarative AST pattern matching and lint rules for Rust.
Read-only structural matching with composable `any` / `all` / `none` grouping,
schema-driven definitions for LLM-perfect query generation, and pre-computed
relation graphs.
## Install
```sh
cargo add ryo-pattern
```
## Quickstart
```rust,ignore
use ryo_pattern::{parse_pattern, RuleEngine};
// Parse a concrete pattern
let pattern = parse_pattern("fn $name($args) -> Result<$ok, $err> { $body }")?;
// Match against AST nodes
let engine = RuleEngine::new();
let matches = engine.run(&pattern, &ast_root);
for m in matches {
println!("matched: {:?} with captures {:?}", m.node, m.captures);
}
```
## API Summary
| `CodePattern` | AST node predicate (structural matching) |
| `parse_pattern` / `ConcreteParser` | Pattern DSL parser |
| `RuleEngine` / `Rule` | Query + message + severity bundles |
| `MatchResult` | Match outcome with `{$VAR: Node}` captures |
| `generator::*` | Template-based code generation |
| `loader::*` | Pattern loading from files |
## Status
API surface considered stable for the v0.1.0 release. Pattern matching
remains read-only; mutations are owned by downstream crates such as
[`ryo-mutations`](https://crates.io/crates/ryo-mutations).
## License
Licensed under either of [Apache-2.0](https://github.com/ynishi/ryo-rs/blob/main/LICENSE-APACHE)
or [MIT](https://github.com/ynishi/ryo-rs/blob/main/LICENSE-MIT) at your option.