legal-ai-agent: Instructions file for Claude Code

CLAUDE.md

legal-ai-agent CLAUDE.md is an instructions file for Claude Code from WIndFate/legal-ai-agent. It costs 1,990 tokens per session, scanned A, original, MIT.

Repository instructions for ContractGuard, an open-source AI project for analysing risks in Japanese contracts.

In plain words
What is it for?
Starting tasks correctly, running the application and checks through Docker, testing backend and localisation changes, and keeping CLAUDE.md and AGENTS.md aligned.
Why use it?
They set rules for safe work in the repository, including required reading, Docker-only operation, testing, file synchronisation, and commit discipline.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: mentions CLAUDE.md; mentions Claude Code; mentions AGENTS.md.

This is WIndFate/legal-ai-agent's own configuration. It tells Claude Code how to work on legal-ai-agent itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything legal-ai-agent configures →

Reuse

Borrowing it

Nothing to install: this file belongs to WIndFate/legal-ai-agent. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/WIndFate/legal-ai-agent/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/WIndFate/legal-ai-agent

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for legal-ai-agent CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/windfate/legal-ai-agent/claude-md/github.svg)](https://agentmods.dev/instructions/windfate/legal-ai-agent/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/windfate/legal-ai-agent/claude-md"><img src="https://agentmods.dev/badge/instructions/windfate/legal-ai-agent/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for legal-ai-agent CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/windfate/legal-ai-agent/claude-md"><img src="https://agentmods.dev/badge/instructions/windfate/legal-ai-agent/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,990 This file is loaded in full into every session.
When invoked 1,990 The same file — it is already loaded in full.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01990 $0.01990
Opus 5 $0.00995 $0.00995
Sonnet 5 $0.00398 $0.00398
Haiku 4.5 $0.00199 $0.00199

Measured 9d ago against content hash a4932850370c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

legal-ai-agent CLAUDE.md scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl http://localhost:8000/api/health # 健康检查
CLAUDE.md · 121 lines

How it starts

The opening of the file, as written. The whole thing — 121 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Repository Agent Instructions — 契約チェッカー (ContractGuard)

This file is mirrored in AGENTS.md for tool compatibility. Keep the two files in sync on every edit.

This document contains behavior rules for AI agents working in this repo. Keep implementation details in the README files and source code; do not duplicate long status snapshots here.


开始任务前

先读 README.md 和与任务直接相关的源码 / 测试。CLAUDE.md / AGENTS.md 只写行为规则,不保存产品路线图、进度快照或审计清单。


项目一句话

面向日文合同风险分析场景的开源 AI 工程案例。技术栈:LangGraph + pgvector + FastAPI + React/Vite + Redis + KOMOJU reference implementation。合同分析后立即删除,报告 Redis 缓存 72h。


运行与验证(只用 Docker,严禁直接跑 Python)

docker compose up --build              # 启动
docker compose up --build backend      # 后端改动后
docker compose logs -f backend         # 查日志
curl http://localhost:8000/api/health  # 健康检查

Docker 纪律:

  • 优先 docker compose exec,避免 docker compose run(会留下 *-run-* 孤儿容器阻塞 down)。
  • 如必须用 run,加 --rm 并立即清理。

本地回归脚本(完成一个逻辑单元后自行跑):

scripts/smoke_local_flow.sh      # 端到端冒烟
scripts/check_locale_keys.sh     # 9 语言 i18n key 一致性
scripts/check_rag_eval.sh        # RAG Recall@5 / MRR 基线
scripts/run_backend_pytests.sh   # 后端 pytest

Git 提交纪律(强约束)

每完成一个最小逻辑单元立即提交。禁止攒改动。

  • 新文件 = 一次提交;同一功能模块的 2–5 个相关文件 = 一次提交。
  • Bug 修复、文档更新、依赖/配置变更各自独立提交。
  • 提交信息清晰描述做了什么(例:Add SQLAlchemy Order/Report/Referral models),不要写 Update multiple files
  • ❌ 提交消息不得包含 Co-Authored-By 或任何 Claude 签名。
  • ❌ 提交前不要跳 hook--no-verify 等)。

文档同步纪律

功能里程碑(完整模块完成)时,同步更新 README.md + README_CN.md + README_JA.md,必要时同步 CLAUDE.md + AGENTS.md。日常微小提交不需要每次都更新全部文档。

分工底线:

  • AI 行为规则 → CLAUDE.md + AGENTS.md(镜像)
  • 开源项目说明 / 运行方式 / 架构摘要 → README.md + README_CN.md + README_JA.md

架构铁律(Do-Not-Break)

以下约定是刻意的设计,不要"顺手优化回去":

  1. RAG 在 tool 内部analyze_clause_risk(clause_text) 直接调用 get_store().search()不要加回 retrieve_knowledge 节点或 search_legal_knowledge tool;不要把 RAG 结果预注入 prompt。
  2. AgentState 字段固定contract_text / clauses / risk_analysis / review_report / messages / target_language不要加回 rag_resultscurrent_clause_index
  3. 逐条分析,非整合同对话analyze_risks 对每个 clause 单独跑 analyze_clause_risk → gpt-4o 分级 → 仅高/中风险触发 generate_suggestion。不要恢复"整合同一轮大 prompt"模式。
  4. 合同文本永不入向量库legal_knowledge_embeddings 只存 e-Gov 法条;用户合同仅查询,分析完即删。
  5. 报告翻译时保持日文原文referenced_lawclause_number 必须保留日文;risk_reason / suggestion / summary / risk_level / overall_risk 才翻译到目标语言。见 _translate_report()
  6. ReviewPage 不暴露内部工具名:不要把 analyze_clause_risk 这类名字显示给终端用户。
  7. analysis_executor 持久化事件流是主链路:HTTP 不再由单次 SSE POST 直接驱动分析。前端通过 status + events/?after_seq= + stream?after_seq= 恢复。
  8. 失败终止 vs 继续分析parse_contract 判定非合同时立刻以 error_code = non_contract_document 终止,不要继续走 risk review。ReviewPage 用 error_code 而非本地化 error_message 判断失败类型。
  9. KOMOJU session 不发送 payment_types:方法由商户账号审核控制;不要在代码里列支付方式白名单。
  10. 订单 UUID 路径统一走 routers/_helpers.parse_order_id:非法 UUID 返回 404,不要暴露 SQL DataError 500。
  11. OCR 供应商固定为 Google Cloud Vision:图片和扫描 PDF 统一走 DOCUMENT_TEXT_DETECTION不要换回 GPT-4o Vision,也不要恢复“付款前低成本 OCR / 付款后正式 OCR”双层路径。遗留的 temp_uploads.pyorders.temp_upload_* 列及 upload_token / upload_name / upload_mime_type 请求字段已在迁移 011 中彻底移除,不要恢复。
  12. 高成本预付费路径必须 fail-closed:OCR / preview 的 Redis 或预算守卫异常必须直接拒绝请求,不要在高成本匿名入口上做 fail-open。

Read the full file on GitHub · 121 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 121 lines · 1,990 tokens per session scan A a4932850370c

Subscribe to this mod's changes

legal-ai-agent CLAUDE.md is an instructions file published in the GitHub repository WIndFate/legal-ai-agent (1 stars, last pushed 4mo ago), licensed MIT. It adds 1,990 tokens to every session, about $0.0100 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories

next.js AGENTS.md

AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,296 tokens

codex AGENTS.md

AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.

openai/codex · 5,153 tokens

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 6,785 tokens

spec-kit AGENTS.md

AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.

github/spec-kit · 7,104 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).

microsoft/vscode · 5,001 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,469 tokens