best-practices

best-practices is a cursor rule for Cursor from lazylagom/context-compose-mcp. It costs 0 tokens per session (1,808 once invoked), scanned A, original, MIT.

Coding guidelines focused on clear TypeScript types, small focused functions, dependency injection, and readable names.

In plain words
What is it for?
Use them when designing interfaces, modeling loading and error states, writing type guards, and reviewing TypeScript code.
Why use it?
They reduce confusing code and make project data and program states easier to understand and maintain.

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/lazylagom/context-compose-mcp/best-practices
Clone the repo
git clone --depth 1 https://github.com/lazylagom/context-compose-mcp

Made for: Cursor.

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 best-practices

README.md
[![agentmods](https://agentmods.dev/badge/rules/lazylagom/context-compose-mcp/best-practices.svg)](https://agentmods.dev/rules/lazylagom/context-compose-mcp/best-practices)
Your own site
<a href="https://agentmods.dev/rules/lazylagom/context-compose-mcp/best-practices"><img src="https://agentmods.dev/badge/rules/lazylagom/context-compose-mcp/best-practices.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,808 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.00000 $0.01808
Opus 5 $0.00000 $0.00904
Sonnet 5 $0.00000 $0.00362
Haiku 4.5 $0.00000 $0.00181

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

Security

Grade A, and why

best-practices 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 4d 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/best-practices.mdc · 309 lines

How it starts

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

Best Practices and Code Patterns

Code Writing Principles

Clean Code Principles

  • Single Responsibility Principle: Each function and class has only one clear responsibility
  • Clear Naming: Variable, function, and class names clearly express their purpose
  • Small Functions: Functions are limited to a size that fits on one screen
  • Dependency Injection: Use injection structure rather than hardcoded dependencies

TypeScript Best Practices

Type Definitions
// Good example: Clear and specific types
interface ContextConfig {
  readonly version: number;
  readonly kind: 'task' | 'role' | 'workflow';
  readonly name: string;
  readonly description: string;
  readonly context: {
    workflow?: string;
    personas?: readonly string[];
    rules?: readonly string[];
    mcps?: readonly string[];
  };
}

// 피해야 할 예시: any 타입 사용
const config: any = loadConfig();
유니온 타입 활용
// 상태 관리에 유니온 타입 사용
type LoadingState = 
  | { status: 'loading' }
  | { status: 'success'; data: ContextConfig }
  | { status: 'error'; error: string };
타입 가드 패턴
function isContextConfig(obj: unknown): obj is ContextConfig {
  return typeof obj === 'object' && 
         obj !== null && 
         'version' in obj && 
         'kind' in obj;
}

File Structure Best Practices

Module Separation Principles

src/
├── cli/
│   ├── commands/        # CLI command modules
│   ├── utils/          # CLI utilities
│   └── index.ts        # CLI entry point
├── core/
│   ├── context/        # Context-related logic
│   ├── workflow/       # Workflow engine
│   ├── notification/   # Notification system
│   └── types.ts        # Common type definitions
├── schemas/
│   ├── context.ts      # Context schemas
│   ├── workflow.ts     # Workflow schemas
│   └── index.ts        # Schema exports
└── types/
    ├── cli.ts          # CLI-related types
    ├── mcp.ts          # MCP-related types
    └── index.ts        # Type exports

Read the full file on GitHub · 309 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. 4d ago First seen · 309 lines · 0 tokens per session scan A b1aa0c17dcc5

Subscribe to this mod's changes

best-practices is a cursor rule published in the GitHub repository lazylagom/context-compose-mcp (1 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,808 tokens. 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-31.