Precis CLI
Local-first data validation engine — define schemas and constraints in YAML, validate CSV / Excel / JSON with a single command. 本地优先的数据校验引擎:用 YAML 定义表结构与约束规则,一条命令校验 CSV / Excel / JSON。
Alpha — 核心功能稳定,配置格式有版本保障(V2)。
安装
pip install precis-cli # 需要 Python >= 3.12
# 或免安装直接运行(需要 uv)
uvx --from precis-cli precis --version
快速上手
# 1. 从数据文件推断 schema 草稿
precis infer-schema orders.csv > schemas/orders.schema.yaml
# 2. 在项目清单 project.precis.yaml 中登记 schema 与约束文件
# (格式见下方示例)
# 3. 执行校验
precis validate --manifest project.precis.yaml --format json
退出码契约(CI / AI agent 友好):
| 退出码 | 含义 |
|---|---|
0 |
校验通过 |
1 |
校验完成,发现数据违规(详情见 JSON 输出的 errors) |
2 |
工具自身错误(参数错误、文件不存在、异常崩溃) |
配置示例(V2 YAML)
project.precis.yaml:
version: 2
project:
id: my-project
name: 订单数据校验
schemas:
- id: orders
path: schemas/orders.schema.yaml
constraints:
- id: orders_amount_range
path: constraints/orders_amount_range.constraint.yaml
constraints/orders_amount_range.constraint.yaml:
version: 2
id: orders_amount_range
type: Range
enabled: true
refs:
table_id: orders
column_id: amount
params:
min: 0
max: 1000000
boundary_mode: inclusive
10 种约束类型
NotNull 非空 · Unique 唯一 · AllowedValues 枚举 · Range 数值区间 ·
ForeignKey 跨表引用 · Conditional 条件约束 · Scripted 脚本表达式 ·
Charset 字符集 · DateLogic 日期逻辑 · Composite 组合约束
数据类型:string / integer / float / decimal / boolean / date。
大文件(>500MB)自动分块加载。
与 AI Agent 集成
--format json 输出为机器可读契约(含行级错误定位与约束来源文件回溯),
可直接被 AI 编程助手消费:
- MCP server:
pip install "precis-cli[mcp]"后运行precis-mcp(stdio), 提供validate_data/infer_schema/check_config/describe_constraints四个工具 - Kimi Code 插件:
/plugins install https://github.com/AirSaiga/Precis - CLI 自带 AI 命令(自然语言生成/修改校验配置,独立于宿主 agent):
pip install "precis-cli[ai]",然后precis ai chat或precis ai ask "..."
链接
- 仓库与文档:https://github.com/AirSaiga/Precis
- 问题反馈:https://github.com/AirSaiga/Precis/issues
- 桌面 GUI 版本(画布式可视化编辑)见仓库 releases
License: Apache-2.0
Release files for precis-cli 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| precis_cli-0.1.8.tar.gz | 798.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| precis_cli-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.1 MB
Release files / precis_cli-0.1.8.tar.gz
| Download URL | precis_cli-0.1.8.tar.gz |
|---|---|
| Size | 798.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9477964380556e619cccb0d240885eb300c2c479942d2d34a11f56b951f78cbf
|
|
BLAKE2b-256 checksum How to use checksums |
12d9a9c8aad53b58f93953d73709e3b21b4b4671fb2237ea2af459200ca1cbf0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 22, 2026.
Transparency logRelease files / precis_cli-0.1.8-py3-none-any.whl
| Download URL | precis_cli-0.1.8-py3-none-any.whl |
|---|---|
| Size | 1.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7da75cfd773c056e7c2e8bfaddd668e51bc7bd5e79135444650aa0297d92459d
|
|
BLAKE2b-256 checksum How to use checksums |
096cb357c9b1d9f5938972f8afdf35d3183a986b2bf69a0812c5bfba4183f7e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 22, 2026.
Transparency log