Make custom ast-grep diagnostics easy to set up, share, and expose to AI agents
Project description
Write a custom lint rule once and it becomes a live diagnostic in your terminal, your editor, and your AI agent's feedback loop.
byor is a small CLI around ast-grep, a fast
structural search-and-lint tool. ast-grep scan lints from the terminal and
ast-grep lsp shows diagnostics in your editor; byor arranges plain rule files
and configuration so both work without setup, then adds the two things ast-grep
leaves out: sharing rules across your repositories, and feeding their
diagnostics back into AI coding agents.
# .byor/rules/project/no-print.yml
id: no-print
language: python
severity: warning
message: Use the logging module, not print, in library code.
rule:
pattern: print($$$ARGS)
metadata:
byor:
agent_prompt: >
Replace this print with a module-level logger,
logging.getLogger(__name__), at the appropriate level.
message is what you read in the terminal and editor; agent_prompt is the
directive byor hands your AI agent when it trips the rule.
Install
uv tool install byor # or `uvx byor` to try without installing
byor install # set up the skill + your agents' hooks (once)
byor init # add byor to a repo
byor bundles ast-grep, so Python 3.11+ is the only requirement. byor install
registers your editor and agent integrations machine-wide; byor init adds a
repository's rule directories and sgconfig.yml.
docs/ai-agents.md covers what each step writes.
You can also let your AI coding agent handle it: open it in the repo and ask it to set up byor.
Terminal and editor
A rule under .byor/rules/ is an ordinary ast-grep rule, so the ordinary tools
read it:
ast-grep scan # lint the repo
ast-grep scan src/ # ...or a path
For live in-editor diagnostics, point your editor's ast-grep integration at
ast-grep lsp: rules light up as you type and reload when you edit them.
(editor setup.)
Rule scopes
The same rule format lives at three scopes:
| Scope | Lives in | Shared with |
|---|---|---|
project |
.byor/rules/project/ |
Your team (committed) |
local |
.byor/rules/personal/local/ |
You, this repo only |
global |
~/.config/byor/rules/ |
You, in every repo |
Global rules are your personal standards; byor makes them apply in every repo. Project and local rules override a global rule with the same ID, so a team policy or a local experiment takes precedence. See docs/rules.md for the rule workflow and docs/sync-model.md for how byor copies global rules into each repo.
With AI coding agents
Agents can both obey your rules and write new ones:
- Feedback. A post-edit hook runs
byor agent-checkafter the agent edits a file and feeds the diagnostics back into its context, scoped to the lines it changed, so it fixes violations before moving on. - Capture. A bundled skill turns durable feedback ("never do this", "always
do that") into an ast-grep rule: the agent drafts it, confirms once, and runs
byor add. When a linter or type checker fits better, the skill offers that instead.
byor install wires up the agents you pick (once, machine-wide); byor hook
adds or drops one later.
byor install --agents claude-code,codex
byor hook install --agent cursor
byor supports six harnesses:
| Harness | Skill | Real hook | Diagnostic precision |
|---|---|---|---|
| Claude Code | yes | PostToolUse |
the edited lines |
| Codex | yes | PostToolUse |
the patched lines |
| Copilot CLI | yes | postToolUse |
best-effort path |
| Cursor | yes | postToolUse |
the edited lines |
| OpenCode | yes | tool.execute.after plugin |
the changed file |
| Pi | yes | tool_result extension |
the changed file |
A checks: section in .byor/config.yml (or your global config) runs extra
command-line tools (a linter, a type checker, anything) on the changed files and
folds their output into the same feedback. See
docs/ai-agents.md.
Continuous integration
Project rules are committed files that work with ast-grep, so CI doesn't need
byor: a fresh clone already has everything ast-grep scan reads. Scan with
--error so warnings fail the build (a plain scan exits 0 on warnings):
- run: npm install -g @ast-grep/cli
- run: ast-grep scan --error
Commands
Setup. You run these once to get going.
byor install Register byor's AI integrations (machine-wide)
byor init Initialize byor in a repository
byor hook Add or remove an agent integration
byor doctor Check that everything is wired up
Rules. Your agent runs these as it captures and manages rules for you.
byor add Create a rule in a scope
byor list Show rules and where they come from
byor edit Open a rule in $EDITOR
byor remove Delete a rule
byor promote Move a personal rule into shared project rules
byor exclude Disable a global rule in this repository
byor include Re-enable an excluded global rule
Automatic. byor runs these itself: the post-edit hook and self-heal.
byor agent-check Render diagnostics for your agent
byor sync Mirror global rules into the repo
Every command takes --help, and repo-operating commands take --repo PATH
(default: search upward from the current directory).
Documentation
- docs/rules.md — rule format, scopes, and the rule workflow
- docs/ai-agents.md — AI agent integration and
agent-check - docs/sync-model.md — copies, self-healing, and git hooks
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file byor-0.1.0.tar.gz.
File metadata
- Download URL: byor-0.1.0.tar.gz
- Upload date:
- Size: 54.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d52e6c076fc4b471b5076acb5f28e8573b1f26ef8e4b74a5530d3db1a761df86
|
|
| MD5 |
99a23395198a04def08bea7ded08aa88
|
|
| BLAKE2b-256 |
620b75923c12d1fe85b8e23d09efa33073232bc9b4ff219c0d6d4393153450d6
|
Provenance
The following attestation bundles were made for byor-0.1.0.tar.gz:
Publisher:
release.yml on RyanSaxe/byor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
byor-0.1.0.tar.gz -
Subject digest:
d52e6c076fc4b471b5076acb5f28e8573b1f26ef8e4b74a5530d3db1a761df86 - Sigstore transparency entry: 1819025468
- Sigstore integration time:
-
Permalink:
RyanSaxe/byor@19decbc72b741b9998a073555c232bcb03cd46e0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RyanSaxe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@19decbc72b741b9998a073555c232bcb03cd46e0 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file byor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: byor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 71.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ac2a443ccdddfba66b85f1e2f8323c06a2f1c5281f0e640b7a6aeb0e66e9006
|
|
| MD5 |
53010e4913dd4877cedec6afe9ecc4c7
|
|
| BLAKE2b-256 |
ff0b3e7b2510e94b58ad2b0e5695d99b431784d74743b17081178551ee2387f2
|
Provenance
The following attestation bundles were made for byor-0.1.0-py3-none-any.whl:
Publisher:
release.yml on RyanSaxe/byor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
byor-0.1.0-py3-none-any.whl -
Subject digest:
1ac2a443ccdddfba66b85f1e2f8323c06a2f1c5281f0e640b7a6aeb0e66e9006 - Sigstore transparency entry: 1819025516
- Sigstore integration time:
-
Permalink:
RyanSaxe/byor@19decbc72b741b9998a073555c232bcb03cd46e0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RyanSaxe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@19decbc72b741b9998a073555c232bcb03cd46e0 -
Trigger Event:
workflow_dispatch
-
Statement type: