Skip to main content

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 "..."

链接

License: Apache-2.0

Release files for precis-cli 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for precis-cli 0.1.9
File Size Uploaded
precis_cli-0.1.9.tar.gz 837.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for precis-cli 0.1.9
File Interpreter ABI Platform
precis_cli-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 2.1 MB

Release files / precis_cli-0.1.9.tar.gz

Download URL precis_cli-0.1.9.tar.gz
Size 837.1 kB
Tags Source
SHA-256 checksum
How to use checksums
999392bdc31d6a47aa9bc7188568a878e735a19bbc44fac319e028cc95602882
BLAKE2b-256 checksum
How to use checksums
f750d48e35d09a6a006fe544f60c54ba2cb14a70752b2ab7c0ae09ff25d72f2b
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 25, 2026.

Transparency log

Release files / precis_cli-0.1.9-py3-none-any.whl

Download URL precis_cli-0.1.9-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
1b12c637831e213d12386d7225894d491e64367f5e8c5f2490c79ebedca6c6c5
BLAKE2b-256 checksum
How to use checksums
677a60eac111765729d8da5ad558bc6a231c1326b013255cf69d69e13500bbb9
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 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page