g-project-structure

A project-structure rule for Go applications using domain-driven design, an approach that organizes code around business concepts. It describes folders for APIs, services, domain models, infrastructure, deployments, documentation, and shared tools.

In plain words
What is it for?
Use it as a Cursor coding rule when creating or reviewing Go repositories with layered services, external clients, databases, messaging, and deployment configurations.
Why use it?
It gives developers a consistent way to place code in large Go projects and separates business logic from technical integrations.

Cursor rule

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/xyzbit/ai-coding/g-project-structure
Clone the repo
git clone --depth 1 https://github.com/xyzbit/AI-Coding
Per session 39 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 640 The whole file, excluding the scripts and references it only reads on demand.
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.00039 $0.00640
Opus 5 $0.00019 $0.00320
Sonnet 5 $0.00008 $0.00128
Haiku 4.5 $0.00004 $0.00064

Measured 2d ago against content hash 4a2c08587c1e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

g-project-structure 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 2d 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.

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.

cursor/rules/g-project-structure.mdc · 69 lines

What it actually says

项目目录结构分析

1. 顶层目录结构

api/ - API 定义目录

cmd/ - 服务入口目录

internal/ - 内部业务代码

遵循 DDD (领域驱动设计) 分层架构:

  • application/ - 应用层
    • command/ - 命令处理
    • query/ - 查询处理
    • service/ - 应用服务
  • domain/ - 领域层
    • model/ - 领域模型
    • service/ - 领域服务
  • infrastructure/ - 基础设施层
    • client/ - 外部客户端
    • converter/ - 数据转换器
    • repository/ - 数据仓储
    • publisher/ - 消息发布
  • presentation/ - 表现层
    • assembler/ - 数据组装
    • controller/ - 控制器
    • provider/ - 服务提供者
    • subscriber/ - 消息订阅者

pkg/ - 公共代码包

包含各种通用工具和基础设施:

  • 数据库相关:mysql/, redis/, clickhouse/
  • 消息队列:amqp/, kafka/
  • 中间件:middleware/
  • 工具类:tools/, filex/, stringx/
  • SDK:sdk/
  • 监控和追踪:metricx/, sentry/

deployments/ - 部署配置

按环境划分部署配置:

  • pre/ - 预发布环境
  • prod/ - 生产环境
  • test/ - 测试环境 每个环境下可能包含:
  • rpc/ - RPC 服务配置
  • web/ - Web 服务配置
  • cron/ - 定时任务配置
  • pubsub/ - 消息订阅配置

docs/ - 项目文档

scripts/ - 脚本文件

  • busness/ - 业务相关脚本
  • db/ - 数据库脚本
  • shell/ - Shell 脚本

third_party/ - 第三方依赖

  • google/ - Google 相关依赖
  • openapiv3/ - OpenAPI 规范

2. 主要业务模块

项目包含多个业务模块,每个模块都遵循相同的 DDD 架构: ...

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. 2d ago First seen · 69 lines · 39 tokens per session scan A 4a2c08587c1e

Subscribe to this mod's changes

g-project-structure is a cursor rule published in the GitHub repository xyzbit/AI-Coding (21 stars, last pushed 10mo ago), licensed Apache-2.0. It adds 39 tokens to every session and 640 once invoked, about $0.0002 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.