typescript-conventions

TypeScript coding rules for an ESM project, where modules use import and export statements, including file layout, types, naming, and compiler settings.

In plain words
What is it for?
Use it when writing or reviewing TypeScript files, imports, interfaces, shared types, names, and compiled source locations.
Why use it?
It keeps new code consistent with the project's module system and existing TypeScript structure.

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/superagent-ai/grok-cli/typescript-conventions
Clone the repo
git clone --depth 1 https://github.com/superagent-ai/grok-cli

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 517 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.00517
Opus 5 $0.00000 $0.00259
Sonnet 5 $0.00000 $0.00103
Haiku 4.5 $0.00000 $0.00052

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

Security

Grade A, and why

typescript-conventions 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/typescript-conventions.mdc · 55 lines

What it actually says

TypeScript Conventions

Module System

  • This is an ESM project ("type": "module" in package.json).
  • Always use ES module import/export syntax — never require().
  • When importing local modules, include the .js extension (TypeScript compiles .ts.js):
    import { GrokAgent } from "./agent/grok-agent.js";
    

TypeScript Configuration

  • Target: ES2022, Module: ESNext, JSX: react
  • strict: false and noImplicitAny: false — the codebase does not enforce strict mode.
  • moduleResolution: "Bundler" is used.
  • Source files live in src/, compiled output goes to dist/.

Type Practices

  • Prefer explicit interfaces for public API boundaries (e.g. ChatEntry, ToolResult, GrokToolCall).
  • Use type imports when importing only types:
    import type { ChatCompletionMessageParam } from "openai/resources/chat";
    
  • any is acceptable where strict typing would add friction, but prefer narrower types when practical.
  • Shared types belong in src/types/index.ts.

Naming Conventions

  • Files: kebab-case (grok-agent.ts, chat-interface.tsx, settings-manager.ts).
  • Classes: PascalCase (GrokAgent, TextEditorTool, BashTool).
  • Interfaces/Types: PascalCase (ChatEntry, ToolResult, StreamingChunk).
  • Functions/variables: camelCase (processUserMessage, loadApiKey).
  • Constants: camelCase or UPPER_SNAKE_CASE for true constants (GROK_TOOLS).

Error Handling

  • Catch errors as error: any and access .message for display.
  • Tool execution methods return ToolResult objects ({ success, output?, error? }) rather than throwing.
  • Use process.exit(1) for fatal CLI errors.

ESLint Rules

  • @typescript-eslint/no-unused-vars: error
  • @typescript-eslint/no-explicit-any: warn

Run bun run lint to check and bun run typecheck to verify types.

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 · 55 lines · 0 tokens per session scan A 534ba35cddb4

Subscribe to this mod's changes

typescript-conventions is a cursor rule published in the GitHub repository superagent-ai/grok-cli (3,441 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 517 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-30.