rulepack
Run ast-grep checks from shared, versioned rule packs in any repo.
Status: shared source pinning is available. Use rulepack packs to pin and inspect Git and local sources. Running their checks is the next step in pack-sources. Repos that rely on mstack's bundled checks can keep using mstack v6.x in the meantime.
Why
Agents write more of the code now, and reviewing it means correcting the same preferences again and again: a naming habit, a test layout, an import boundary. If an agent writes the code and you review it, it should write the code the way you would.
Prose rules in Markdown help, but an agent follows them only some of the time. rulepack turns those preferences into static, deterministic checks wherever a check can express them, so a broken rule fails the same way every time and the agent fixes it before you see the diff. Packs make the rules portable: write them once, version them, and select them from any repo.
Install
You need uv. Once the first release is available on PyPI, install the CLI with:
uv tool install rulepack
To run it without installing:
uvx rulepack --version
Until the first PyPI release is available, install from the GitHub release tag:
uv tool install git+https://github.com/justmatias/rulepack@v0.12.0
Or run it without installing:
uvx --from git+https://github.com/justmatias/rulepack@v0.12.0 rulepack --version
Usage
Scaffold the layout in a repo, then lint it:
rulepack init --pre-commit --ci github --poe # shows the plan and asks first
rulepack lint
| Command | What it does |
|---|---|
rulepack init |
Writes .rulepack.toml, and with --checks-dir DIR an ast-grep sgconfig with empty rules/ and rule-tests/ for the repo's own checks. --pre-commit, --ci github and --poe add the hooks, the workflow and the poe tasks (in pyproject.toml, or poe_tasks.toml when there is none). It shows the plan, asks first (--yes skips, --dry-run writes nothing) and never overwrites a file, so a second run changes nothing. |
rulepack lint |
Runs the checks below. |
rulepack config |
Prints the resolved config and where each value comes from (--json for JSON). |
rulepack hook post-edit, rulepack hook stop |
Agent hooks (below). |
rulepack lint
rulepack lint [--changed [--base-ref REF] [--staged] | --files FILE ...]
[--only STEP ...] [--skip STEP ...] [--json]
| Step | Runs | Skipped when |
|---|---|---|
test |
ast-grep test -c <sgconfig> --skip-snapshot-tests |
there is no sgconfig at the default path, or its testConfigs hold no test files |
scan |
ast-grep scan -c <sgconfig>, skipping the [scan].exclude globs |
there is no sgconfig at the default path, or --changed or --files selected no file |
- Modes. By default the scan covers the whole repo and warnings don't fail.
--changedscans only the files changed against[changed].base_ref(--base-refoverrides it,--stageduses the staged files) and passes--error, so warnings fail on new or touched code.--filesscans exactly the given files with--error(for pre-commit). - All steps run, even after a failure. The exit code is 1 if any failed, 2 for a usage, config or git error.
--jsonprints{step: {ok, skipped, findings}}. - Tools. ast-grep comes from the environment rulepack runs in.
Configuration
Every command reads an optional .rulepack.toml, found by walking up from the current directory to the git root. A flag wins over the file, and the file over the defaults. Paths are relative to the file. Unknown keys are an error. rulepack ignores .mstack.toml.
sgconfig = "lint/sgconfig.yml" # ast-grep config; a missing default means no local checks
[scan]
exclude = [] # globs every scan skips
extensions = [".py"] # what --changed, --files and the hooks scan
[hooks]
enabled = true
timeout = 10.0 # seconds per agent hook run
[changed]
base_ref = "origin/main"
pre-commit
repos:
- repo: https://github.com/justmatias/rulepack
rev: vX.Y.Z # a release tag
hooks:
- id: rulepack-lint # ast-grep scan of the staged files; warnings fail too
- id: rulepack-rules # rule tests, when a rule or its test changes
GitHub Actions
The action runs the full scan, and on pull requests also the changed-files scan, where warnings fail. Check out with the full history so the base branch exists:
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: justmatias/rulepack@v0.12.0
Inputs: mode (full, changed or both), base-ref, rulepack-version, python-version and working-directory. Every release moves the v<major> tag. On other CI providers, run uvx --from git+https://github.com/justmatias/rulepack@<tag> rulepack lint, and on merge requests the same with --changed --base-ref origin/<base branch>.
Agent hooks
rulepack hook post-edit and rulepack hook stop read a Claude Code, Codex or Cursor hook payload on stdin. They run only in repos with .rulepack.toml. Post-edit scans the edited files; stop scans the changed files, and reports the same findings only once per session. A run that times out or fails logs a warning and lets the agent continue. Set [hooks] enabled = false to turn them off for a repo.
Pack sources
Declare a Git repository or a local folder in .rulepack.toml. Each source
contains a packs.toml manifest that lists its packs and checks.
[sources.mstack]
git = "https://github.com/justmatias/mstack"
ref = "v7.4.0"
[sources.team]
path = "../team-rules"
- Run
rulepack packs lockto pin and fetch Git sources. Commit the generatedrulepack.lockalongside the config. Running it again keeps existing pins whose URL and ref still match. - Run
rulepack packs updateto refresh every Git pin, orrulepack packs update mstackto refresh only the named source. - Run
rulepack packs listto see each source's packs, checks, and locked commit. Add--jsonfor scripts.
Local sources resolve relative to the config file and need no lock entry.
Contributing
Bug reports, ideas and pull requests are welcome. CONTRIBUTING.md covers the setup, the checks to run and how a pull request title decides the release. Report security problems privately, as SECURITY.md describes, and follow the Code of Conduct.
License
MIT. See LICENSE.
Metadata
Release files for rulepack 0.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rulepack-0.12.0.tar.gz | 26.7 kB | With provenance | Details for rulepack-0.12.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rulepack-0.12.0-py3-none-any.whl | Python 3 | none | any | Details for rulepack-0.12.0-py3-none-any.whl |
Total release size: 62.6 kB
Release files / rulepack-0.12.0.tar.gz
| Download URL | rulepack-0.12.0.tar.gz |
|---|---|
| Size | 26.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c511e18ae8550f0e37e6c5b311df6d7fe8449d8cd8b8963d372b5f085edb69e1
|
|
BLAKE2b-256 checksum How to use checksums |
91a74296221ea6ae342ceaf885268472cd14c1e4ce41137e37bf80d0cb24dfe6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / rulepack-0.12.0-py3-none-any.whl
| Download URL | rulepack-0.12.0-py3-none-any.whl |
|---|---|
| Size | 35.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2436ff7044a4e5f960813d30692a5843ff8a6e9b8909226de9e5628994cbdef4
|
|
BLAKE2b-256 checksum How to use checksums |
3a41756038447bd146c31762eaca80e5aba954571d731660ffb6aa03efa126c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for rulepack 0.12.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for rulepack-0.12.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.