cursorrules

A set of Cursor coding rules for the ZhiWei project, covering its Java backend, Vue web app, database, build tools, and development conventions.

In plain words
What is it for?
It helps write or review ZhiWei code consistently, including Java and Vue features, database changes, migrations, and build-related work.
Why use it?
It gives contributors and coding agents one reference for the project's technology choices and implementation standards.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/ntygod/zhiwei/cursorrules
Clone the repo
git clone --depth 1 https://github.com/ntygod/ZhiWei

Made for: Cursor.

Per session 4,236 This file is loaded in full into every session.
When invoked 4,236 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
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 $0.04236 $0.04236
Opus 5 $0.02118 $0.02118
Sonnet 5 $0.00847 $0.00847
Haiku 4.5 $0.00424 $0.00424

Measured yesterday against content hash 97870c67ebd1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cursorrules scanned grade A with 0 findings 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 yesterday.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursorrules · 583 lines

How it starts

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

ZhiWei(知微)项目开发规范

基于项目最新架构文档(docs/ARCHITECTURE.md)和实际技术栈 最后更新:2026-03


一、项目技术栈总览

后端(Spring Boot)

  • 语言: Java 22(优先使用 Record、Sealed Interface、Pattern Matching、Virtual Thread)
  • 框架: Spring Boot 3.5.3
  • AI 集成: Spring AI 1.1.2(Advisor 模式、MCP 支持、结构化输出)
  • 构建: Maven 3.9.x
  • 数据库: SQLite 3.49+(WAL 模式、FTS5 全文索引)+ sqlite-vec 0.1.x(向量存储)
  • 迁移: Flyway 10.x

前端(Vue 3 SPA)

  • 框架: Vue 3.5+(Composition API + <script setup lang="ts">
  • UI 组件库: Reka UI 2.x(不是 shadcn-vue)
  • 样式系统: Tailwind CSS 4.x + CSS Variables
  • 状态管理: Pinia 3.x
  • 路由: Vue Router 4.x
  • 图标库: lucide-vue-next
  • 构建工具: Vite 6.x

二、后端开发规范

2.1 Java 代码风格

必须使用 Java 22 特性

  • Record:用于不可变数据传输对象(DTO)、事件封装
  • Sealed Interface/Class:用于有限状态机、策略模式
  • Pattern Matchinginstanceof + switch 模式匹配
  • Virtual Thread:IO 密集型操作优先使用
// ✅ 正确:使用 Record 作为 DTO
public record ChatRequest(String sessionId, List<Message> messages) {}

// ✅ 正确:Sealed Interface 限制实现
public sealed interface AgentState permits IdleState, RunningState, WaitingState {
    AgentState transition(Event event);
}

// ✅ 正确:Pattern Matching
public String describe(Object obj) {
    return switch (obj) {
        case String s -> "字符串: " + s;
        case Number n -> "数字: " + n;
        case null -> "空值";
        default -> "未知类型";
    };
}

禁止事项

  • 禁止使用 Lombok @Data(改用 Record 或手动定义 getter/setter)
  • 禁止使用 public 字段暴露数据(使用封装)
  • 禁止魔法数字/字符串(使用常量枚举或配置类)

2.2 包结构规范

com.lifepilot/
├── llm/              # 多模型路由、熔断器、故障转移
├── agent/            # Agent 控制循环、状态机、上下文组装
├── tool/             # 工具契约、动态注册、执行管道
├── guardrail/        # 安全护栏策略
├── mcp/              # Model Context Protocol 客户端/服务器
├── memory/           # 四层记忆(工作/情景/语义/程序)
├── knowledge/        # 知识库、文档解析、检索
├── skill/            # Skill 注册、热加载、自扩展
├── interaction/      # CLI/Web/Channel 适配器
├── conversation/     # 对话历史、会话管理
├── datastore/        # 通用数据存储(Schema-Free JSON)
├── workflow/         # YAML 声明式工作流
├── sandbox/          # 代码执行沙箱
├── media/            # 多模态处理
├── sync/             # 外部数据源同步
├── eval/             # Agentic Evals 评估框架
├── multiagent/       # 多 Agent 协作
├── a2a/              # A2A 协议实现
├── marketplace/      # 插件市场
├── meta/             # 元能力
├── prompt/           # Prompt 模板管理
├── notification/     # 统一通知系统
├── observability/    # 轨迹记录、可观测性
└── config/           # 全局配置

Read the full file on GitHub · 583 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. yesterday First seen · 583 lines · 4,236 tokens per session scan A 97870c67ebd1

Subscribe to this mod's changes

cursorrules is a cursor rule published in the GitHub repository ntygod/ZhiWei (137 stars, last pushed 21d ago), licensed MIT. It adds 4,236 tokens to every session, about $0.0212 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.