@codapult/guard

中文文档
0.14.1发布于 2026/11/10MITTypeScriptES Module构建来源已验证近 30 天下载 3143

Local-first architecture guardrails for JavaScript and TypeScript projects, with first-class support for Next.js SaaS and AI-assisted development

原始使用文档
文档目录10 节
  1. Architecture guardrails for AI-assisted development
  2. Catch project-specific regressions
  3. Get started
  4. Use Guard with an AI agent
  5. Choose a GitHub setup
  6. What Guard does
  7. Documentation
  8. For contributors
  9. More from Codapult
  10. License

@codapult/guard

CI Fixtures npm License: MIT Node.js >=20.19 TypeScript MCP Registry MCPSafe codapult-guard MCP server – quality and maintenance score on Glama

Architecture guardrails for AI-assisted development

Codapult Guard helps teams preserve the architecture that makes their project work as it changes. It maps a JavaScript or TypeScript codebase, lets the team approve project-specific boundaries, and checks future changes locally and in CI. AI agents can use the same project context and verification results as developers.

Catch project-specific regressions

A type checker can confirm that code is valid TypeScript. It cannot know that this project requires client components to stay away from persistence modules. Once the team approves that boundary, Guard can detect a violating import in changed files and show which rule was triggered.

Project boundary:  Client → Server Action → Service → Repository → Database
Possible regression: Client ─────────────────────────────────────→ Database

Guard discovers the architecture in the repository; it does not prescribe one universal structure or activate proposed rules without approval.

Get started

Requirements: Node.js >=20.19 and a JavaScript or TypeScript project.

# pnpm
pnpm add -D @codapult/guard
pnpm exec codapult-guard init

# npm
npm install --save-dev @codapult/guard
npx codapult-guard init

Review the generated project model, proposed rules, contracts, and baseline under .codapult/guard/ before relying on the results. Then run Guard's architecture checks:

pnpm exec codapult-guard verify --no-project-checks --tools off

verify can run your configured project checks and detected adapters. The flags above limit this run to Guard's built-in checks. With npm, run npx codapult-guard verify --no-project-checks --tools off. See the complete guide for initialization and daily workflows.

Use Guard with an AI agent

Install a managed instruction block for your agent so it knows when to load Guard context and run verification:

pnpm exec codapult-guard install-agent codex

Supported hosts and MCP setup are in the AI-agent integration guide and host integration guides.

The MCP server uses host-managed local stdio, with no network listener or application-level authentication. The host and operating system control process access and workspace permissions; see the security model.

Choose a GitHub setup

Choose a preset from the existing workflow templates and follow only the hosting steps for that level of protection. Most projects can start with standard PR checks.

PresetUse it whenGuide
PR checksYou want Guard findings and a required check on ordinary pull requests.GitHub PR checks
Trusted PR verificationThe Guard check must come from a protected workflow source, including for fork PRs.Trusted PR setup
Merge queueYour repository merges through a GitHub merge queue.Merge queue setup

If you are unsure, use PR checks first. It is useful CI feedback, but its workflow lives in the project being checked and can be changed by a pull request. Choose trusted verification when the check itself must be protected from that change.

What Guard does

  • Learns project-specific structure, dependencies, boundaries, and existing findings.
  • Checks approved architecture rules and contracts without imposing a universal architecture.
  • Shows change impact and prepares bounded, redacted context for AI review.
  • Runs configured project checks and adapters when enabled; it does not replace them.
  • Produces deterministic CLI, JSON, and SARIF results for local use and CI.

Guard is local-first and does not call an LLM. The AI host owns model access, edits, and its repair loop. Guard complements TypeScript, ESLint or Biome, tests, SAST, and dependency scanners; it does not replace them.

Documentation

For contributors

Maintainer checks and project fixture coverage are documented in the fixture guide and release guide.

More from Codapult

Starting a SaaS from scratch? Codapult is a production-ready Next.js SaaS foundation built for AI-assisted development, with modular architecture, built-in AI, MCP context, and source code under your control.

License

MIT. See LICENSE.

版本与发布记录

@codapult/guard 共发布 21 个版本,首次发布于 2026/09/18;过去 12 个月发布了 21 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.14.1latest2026/11/10今天
0.14.02026/11/09今天
0.13.32026/11/028 天前
0.13.22026/11/018 天前
0.13.12026/11/018 天前
0.13.02026/11/018 天前

关于 @codapult/guard 的常见问题

@codapult/guard 是什么?

Local-first architecture guardrails for JavaScript and TypeScript projects, with first-class support for Next.js SaaS and AI-assisted development

如何安装 @codapult/guard?

在项目目录运行 npm install @codapult/guard,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 codapult-guard,可以用 npx codapult-guard 直接运行。

@codapult/guard 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@codapult/guard 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@codapult/guard 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.19.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@codapult/guard 可以商用吗?

@codapult/guard 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codapult/guard 的下载量有多少?

根据 npm 官方下载统计,@codapult/guard 在 2026/10/10 – 2026/11/08 这 30 天内被下载 3,143 次,日均约 105 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@codapult/guard 还在维护吗?

最新版本 0.14.1 发布于 2026/11/10(今天);至今共发布 21 个版本,其中过去 12 个月发布了 21 个;首次发布于 2026/09/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。