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

Metadata

Release files for precis-cli 0.1.10

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.10
File Size Uploaded
precis_cli-0.1.10.tar.gz 869.8 kB Details

Built distribution (wheel)

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

Total release size: 2.2 MB

Release files / precis_cli-0.1.10.tar.gz

Download URL precis_cli-0.1.10.tar.gz
Size 869.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7c6f839ae374e8081cec269d8759b5dfb7fb0d22e4c9a97325e128e60d6c8dd4
BLAKE2b-256 checksum
How to use checksums
ea6e8b47a5d2f0395d064fb97f89111a4d2967b2d9ccac0f6d21c78ec5fe0402
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 26, 2026.

Transparency log

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

Download URL precis_cli-0.1.10-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
237fbfa2193bc2e5abc7b9a89acff6fc2a3e3ac17660760ea27e9072a36aa4d8
BLAKE2b-256 checksum
How to use checksums
99ced20fd550830a84b4b268accd639330acd8696c317de9177374c87043b0c9
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 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.10 This release

2 release files

0.1.9

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