Groundrule

io.github.Metricall-AI-Lab由 GitHub 账号 Metricall-AI-Lab 发布v0.23.1更新于 Oct 29, 2026

Your repository's engineering standards for coding agents: rules per file, CI check, rule proposals.

已验证STDIO仅桌面知识与记忆开发者工具

概览

AI 生成的概览

通过 MCP 把仓库的工程规范提供给编码智能体,使其能查询适用规则、检查自身改动并提交规则建议。

可以做什么
  • 列出仓库中生效的规范,供智能体遵循
  • 按路径或语言查询即将修改的文件所适用的规则,阻断级规则优先
  • 对智能体未提交的改动、某个基线引用或全部文件运行与 CI 相同的检查,并给出位置和修复方法
  • 当某条纠正应适用于所有人时,向组织的评审收件箱提交规则建议
适用场景
适用于把工程规范以 YAML 形式存放在 git 中的仓库,希望编码智能体在编辑前读取适用规则、在结束前验证改动。主要面向已使用 Groundrule 做本地和 CI 检查的团队。
运行要求
通过 npx 从 npm 包 @groundrule/cli 以 mcp 子命令启动,作为本地 stdio 进程运行。列出规范、查询规则和检查工具可离线使用且无需账号;提交规则建议需要仓库已连接 Groundrule 平台并事先在浏览器中登录。
安装前请注意
当仓库配置了平台且本机已登录时,检查工具会把每条规则的计数上报给工作区,可通过 platform.reports: none 关闭。提交规则建议会把规则内容、理由以及可选的文件和行号发送到平台,且在评审者接受前不会有任何变更。登录凭据保存在本机。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Groundrule,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Groundrule

[npm] [CI] [License] [Docs]

Your engineering standards, taught to every coding agent and checked on every PR.

Write a standard once, as a small YAML file in git. Groundrule:

  • teaches your coding agents. It generates AGENTS.md, CLAUDE.md, Cursor rules, and Copilot instructions containing only the standards that apply, without touching what you wrote by hand. An MCP server and hooks let Claude Code, Codex, Cursor and Copilot follow action policies before each tool call and check their own changes before they finish.
  • checks the code. It runs locally and in CI against your changes or the whole repository, with deterministic checks (files, patterns, dependencies, imports, layout, metrics, change sets), Semgrep, and optional AI checks on the Groundrule platform.
  • tells you why. Every finding names the standard, shows the evidence, says how to fix it, and labels whether it came from a deterministic check or AI.

Everything in this repository works offline and without an account. The Groundrule platform adds a shared rulebook, staged rollout, hosted checks and a compliance report on top of it.

Status: 0.x. Groundrule checks its own repositories with it. The document format is groundrule.dev/v1alpha1 and may still change before 1.0; changes are announced in Discussions.

See it in 60 seconds

[Groundrule in 60 seconds]

Quick start

Thirty seconds, no account, nothing leaves your machine:

bash
npx @groundrule/cli init      # detects your stack, picks packs, writes .groundrule/config.yamlnpx @groundrule/cli sync      # writes AGENTS.md / CLAUDE.md / Cursor / Copilot instructionsnpx @groundrule/cli check     # checks your uncommitted changes
text
 groundrule check · 11 standards · 2 files changed
 ✕ TS-003  No eval or new Function   BLOCKER · deterministic (regex)   src/app.ts:3     eval or new Function in application code     3: return eval(input);   → Parse the input instead: JSON.parse, a schema, or a lookup table of allowed operations.   → groundrule explain TS-003
 Failed  ✓ 7 passed  ✕ 1 failed  ◇ 2 guidance  · 0.1s

A standard

yaml
apiVersion: groundrule.dev/v1alpha1kind: Standardmetadata:  id: DEP-008  title: Use the platform HTTP client  type: forbidden-tech  owner: team:platformspec:  severity: warning  requirement: Backend services must use @acme/http-client for outbound HTTP calls.  examples:    forbidden: ["import axios from 'axios'"]  checks:    - evaluator: dependencies      forbid: [axios, got, node-fetch]      allowInstead: ["@acme/http-client"]

More in examples/foundation.

Commands

CommandWhat it does
groundrule initCreate .groundrule/config.yaml with packs for your stack
groundrule sync [--check] [--upload]Write (or verify) coding-agent instructions; --upload reports what the repository delivers to agents
groundrule check [--base <ref>] [--all]Check changes, a branch, or everything. -f json|sarif|markdown, --summary <file>
groundrule standardsList the standards in effect
groundrule keys generateCreate a signing key pair for check results (RFC 0008)
groundrule verify <run.json> --key <public.pem>Check a run's signature offline
groundrule explain <ID>Why a standard exists, examples, how to comply, exceptions
groundrule doctorCheck configuration, tools, and agent files
groundrule packsList bundled packs
groundrule scan [--json] [--upload]Observe this repository against the whole catalog: stack, agent files, tools, and how every rule would do today. Changes nothing
groundrule propose "<rule>"Propose a rule for your team to review on the platform. --why, --example, --file path[:line]
groundrule mcpServe your standards to coding agents over MCP, let them check their changes and propose rules (see below)
groundrule hooks [--agents <list>] [--remove]Have Claude Code, Codex, Cursor, or Copilot follow action policies before each tool call and run the check when they finish a task (see below)
groundrule loginSign in to your organization on the Groundrule platform (browser approval)
groundrule whoami / logoutShow or remove (and revoke) your saved sign-in

Exit codes: 0 passed, 1 failed, 2 configuration or usage error.

Using the Groundrule platform (optional)

Everything above works offline. If your organization manages its standards on the Groundrule platform, connect a repository instead of listing packs:

bash
npx @groundrule/cli login               # approve this computer in your browsernpx @groundrule/cli init --org acme     # writes platform: { org: acme } to .groundrule/config.yamlnpx @groundrule/cli sync                # your organization's rules, with every customization

groundrule scan --upload shares a scan with your organization so it can see which rules fit each repository. It also imports what you already have as proposals: instructions from AGENTS.md, CLAUDE.md, Cursor, and Copilot files; ESLint, Biome, Ruff, golangci-lint, Checkstyle, PMD, and tsconfig settings that match catalog rules; CODEOWNERS; and the architecture the code already keeps, as proposed boundary rules with the files that would fail each today (RFC 0011; use --no-import to leave these out). Reports contain counts and at most three one-line, redacted snippets per rule (none for security rules, none at all with --no-snippets); --json shows exactly what would be sent. When uploading, the scan also tests your organization's own rules that have checks, drafts included, so you see their impact before publishing them.

groundrule check --upload sends the result to your organization as a compliance record (RFC 0007): which rules were in effect (as a digest anyone with the same rules can recompute), each rule's version, rollout stage and whether it could fail the change, the exceptions that applied, and which coding agents the change's commits declare, from Co-Authored-By trailers and bot authors (counts only; never commit messages or email addresses). Agent counts are a declaration, not proof; leave them out with --no-authorship.

With a signing key in CI (groundrule keys generate, then the private key as GROUNDRULE_SIGNING_KEY), every uploaded run is signed with Ed25519 (RFC 0008); groundrule verify proves later, offline, that a run wasn't altered. The signature covers everything but code snippets. In GitHub Actions, --sigstore signs with the job's own identity instead of a key (RFC 0009, needs id-token: write; opt-in, since the identity and the result's hash go to Sigstore's public log).

What each command takes from the platform depends on the rule's rollout stage: sync writes rules at Teach, Advise, and Enforce into your agent files; check runs Enforce rules as set and Advise rules as warnings. Rules your repository defines in .groundrule/standards/ still apply. In CI, set GROUNDRULE_TOKEN to a token from Settings → API tokens. Sign-ins are saved in ~/.config/groundrule/credentials.json, readable only by you.

Coding agents (MCP)

groundrule mcp is a Model Context Protocol server (stdio) with four tools:

  • list_standards: the rules in effect in the repository, so the agent follows them. Works offline.
  • rules_for: the rules that name the files the agent is about to change (by path or language), blocking first, with how to comply (ADR 0010). The server's instructions tell the agent to call it before editing a file; rules that apply everywhere stay in the agent file. Works offline.
  • check: the same check CI runs, on the agent's uncommitted changes (or since a base ref, or all files). It lists only what the change introduced, with where and how to fix it, so the agent fixes it before it finishes. Works offline. In a repository connected to its workspace, the counts per rule are reported to the workspace (see below).
  • propose_rule: when you correct your agent and say (or agree) that it should apply to everyone, it proposes the rule to your organization's review inbox, with where it came up. Nothing changes until a reviewer accepts it. Needs a connected repository and groundrule login.

Add it to your agent once per repository or user:

bash
claude mcp add groundrule -- npx -y @groundrule/cli mcp          # Claude Code
json
{ "mcpServers": { "groundrule": { "command": "npx", "args": ["-y", "@groundrule/cli", "mcp"] } } }

The JSON form goes in .cursor/mcp.json for Cursor, .vscode/mcp.json for VS Code (as servers), or your agent's MCP settings. Proposals carry the rule, your reason, and a file and line if given; nothing else from the repository is sent.

Hooks: before each action, and when the agent finishes

groundrule hooks adds two hooks to the agent's project settings. A before-tool hook decides what the agent is about to do against your action policies, and a stop hook runs the check every time the agent finishes a task, whether or not it remembered to:

bash
npx @groundrule/cli hooks        # Claude Code, plus Codex, Cursor and Copilot if the repository uses them
AgentFileBefore an actionWhen the check fails
Claude Code.claude/settings.jsonallow, ask or deny, with the reason; the rules for a file ride along before an edit (ADR 0010)The agent is stopped from finishing and told what to fix
Codex.codex/hooks.jsonallow or deny (ask is delivered as deny, with the reason); each developer trusts the hooks once with /hooksThe same
Cursor.cursor/hooks.jsonshell commands, MCP calls and file reads (ask on a read is deny)What to fix is sent as a follow-up message
Copilot (CLI and cloud agent).github/hooks/groundrule.jsonallow, ask or deny (the cloud agent treats ask as deny)The agent takes another turn with what to fix

Existing settings and hooks are kept. Without an action policy the before-tool hook answers nothing, and without a Groundrule configuration neither hook does anything. The stop hook asks once per turn, so an agent that can't fix something isn't kept going forever. Commit the files so every developer's agent runs them; --remove takes the hooks out again.

What agents may do (action policies)

A standard says what the code must be. An action policy (RFC 0017) says what the agent may do: which shell commands, edits, reads, fetches and MCP calls it may run on its own (allow), which a person confirms first (ask, the default), and which are refused (deny). It lives next to your standards, with the same identity, scope, owner, exceptions and rollout stages:

yaml
apiVersion: groundrule.dev/v1alpha1kind: ActionPolicymetadata:  id: ACT-001  title: Never force-pushspec:  severity: blocker  effect: deny  requirement: Never force-push. Ask the developer, or push to a new branch.  when:    actions: [shell]    commands: ["git push --force*", "git push -f*"]

The before-tool hook decides it in the agent's own permission flow, on your computer, in milliseconds, and the reason names the policy and what to do instead. A matching exception in .groundrule/exceptions.yaml lifts it; a wrong decision never holds up the agent, because any problem means no decision. groundrule:packs/agent-actions ships ten policies to start from: force-pushes, history rewrites, hook bypass, piping downloads into a shell, publishing, infrastructure changes, elevated privileges, deleting outside the repository, secret files and CI workflows. Agent files get a section "What you may not do alone", so an agent without the hook knows too.

What the workspace learns. In a repository with platform: in its config, when this computer is signed in, the hook and the MCP check tool send the workspace a report after the agent has its answer (RFC 0012): the agent, which rules found something and how many times, how many files and rules were checked, and whether the agent was stopped. Never a path, a line, a snippet, or anything the agent or you wrote. It is sent with a two-second timeout and every failure is ignored, so it can't slow the agent or change the check. The workspace uses it to show how much is caught before a commit exists. platform.reports: none turns it off; groundrule doctor says which applies. Offline repositories send nothing.

Checks

EvaluatorSourceUse it for
filesdeterministicRequired or forbidden files (CODEOWNERS, .env)
regexdeterministicForbidden or required patterns in code
dependenciesdeterministicForbidden packages (npm, Maven, Gradle, pip, Go, Cargo)
change-setdeterministicRules about a change ("entity changes need a migration")
semgrepstatic analysisSemgrep rules you already have
llmAIA question about the change, answered by Groundrule's hosted checks (RFC 0013); advisory, never fails a change. Reported as not run locally and in CI

Packs

groundrule packs lists the bundled packs (security, TypeScript/Node, React, Python, Java/Spring, Go, Docker, Kubernetes, Terraform, GitHub Actions, HTTP APIs, testing, AI agent hygiene, and what agents may do). Your organization's own packs work the same way: github:your-org/engineering-standards//packs/backend@v1.

GitHub

Metricall-AI-Lab/groundrule-action@v1 checks every pull request, writes a job summary, and uploads findings to code scanning. Source in action/.

Development

bash
pnpm installpnpm check

See CONTRIBUTING.md. Groundrule checks itself: see .groundrule/.

License

Apache-2.0. "Groundrule" is a trademark; see GOVERNANCE.md.

来源:README.md,提交 b815665

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.23.1最新Oct 29, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分