agentleFS
tegojstegojs/tego/.cursor/rules/backend-guidelines.md

tego / rules

Cursor rule1.1k starsChanged 12 months agoApache-2.0View on GitHub

Establish consistent backend development patterns and best practices for Tego core framework. 为 Tego 核心框架建立一致的后端开发模式和最佳实践。 Automatically activated in the following situations: 在以下情况下自动激活:

Files
backend-guidelines.md

Backend Development Guidelines / 后端开发指南

Purpose / 目的

Establish consistent backend development patterns and best practices for Tego core framework.

为 Tego 核心框架建立一致的后端开发模式和最佳实践。

When to Use This Guide / 何时使用此指南

Automatically activated in the following situations: 在以下情况下自动激活:

  • Creating or modifying core packages / 创建或修改核心包
  • Building server-side functionality / 构建服务端功能
  • Implementing middleware / 实现中间件
  • Database operations / 数据库操作
  • Error handling / 错误处理
  • Configuration management / 配置管理

Quick Start / 快速开始

New Package Checklist / 新包清单

  • Package Structure / 包结构:Clear directory organization / 清晰的目录组织
  • Exports / 导出:Clear public API / 清晰的公共 API
  • Type Definitions / 类型定义:Complete TypeScript types / 完整的 TypeScript 类型
  • Dependencies / 依赖:Minimal dependencies / 最小化依赖
  • Testing / 测试:Unit tests + integration tests / 单元测试 + 集成测试

Package Structure / 包结构

Core Package Structure / 核心包结构

packages/core/src/
├── index.ts            # Main exports / 主导出
├── types.ts            # Type definitions / 类型定义
├── utils/              # Utility functions / 工具函数
├── classes/            # Core classes / 核心类
└── __tests__/          # Tests / 测试

Server Package Structure / 服务端包结构

packages/server/src/
├── index.ts            # Main exports / 主导出
├── server.ts           # Server class / 服务器类
├── middleware/         # Middleware / 中间件
└── types.ts            # Type definitions / 类型定义

Core Patterns / 核心模式

1. Application Class / Application 类

import { Application } from '@tego/core';

const app = new Application({
  database: {
    dialect: 'postgres',
    // ...
  },
});

await app.load();

2. Database Operations / 数据库操作

import { Database } from '@tachybase/database';

const db = new Database({
  dialect: 'postgres',
  // ...
});

// Define collection / 定义集合
db.defineCollection({
  name: 'users',
  fields: [
    { name: 'name', type: 'string' },
  ],
});

3. Dependency Injection / 依赖注入

import { Container } from '@tachybase/di';

const container = new Container();

container.bind('UserService').to(UserService);
const userService = container.get('UserService');

Best Practices / 最佳实践

  1. Single Responsibility / 单一职责:Each package has one clear purpose / 每个包有单一明确的目的
  2. Minimal Dependencies / 最小依赖:Avoid unnecessary dependencies / 避免不必要的依赖
  3. Type Safety / 类型安全:Fully utilize TypeScript type system / 充分利用 TypeScript 类型系统
  4. Clear API / 清晰的 API:Export only what's needed / 只导出需要的
  5. Test Coverage / 测试覆盖:Write tests for core functionality / 为核心功能编写测试

Download now (ZIP)

Trending

Quiet this year.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the tegojs/tego repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about tegojs/tego

The biggest 5 of 40 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 40

Talked about on GitHub (40 times).

On GitHub · 40

35 more on GitHub

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.