code-style

A set of TypeScript coding rules for the openapi-to-cli project. TypeScript is a programming language, and these rules cover naming, types, files, comments, and formatting.

In plain words
What is it for?
Use it when adding or changing TypeScript source files, tests, documentation, or public functions in that project.
Why use it?
It keeps code consistent and helps catch unsafe or unclear implementation choices.

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/evilfreelancer/openapi-to-cli/code-style
Clone the repo
git clone --depth 1 https://github.com/EvilFreelancer/openapi-to-cli

Made for: Cursor.

Per session 658 This file is loaded in full into every session.
When invoked 658 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.00658 $0.00658
Opus 5 $0.00329 $0.00329
Sonnet 5 $0.00132 $0.00132
Haiku 4.5 $0.00066 $0.00066

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

Security

Grade A, and why

code-style 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.

.cursor/rules/code-style.mdc · 56 lines

How it starts

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

Code style (TypeScript)

Applies to every .ts file in src/ and tests/.

General

  1. All code comments and identifiers in English. Documentation files in English.
  2. New files end with a single trailing newline.
  3. Straight double quotes " for string literals. Regular hyphen -, not em-dashes, in any English prose inside code or docs.
  4. Default to no comments. Add a comment only when the why is non-obvious (workaround, hidden constraint, subtle invariant). Identifiers should carry intent.

TypeScript

  • strict: true in tsconfig.json. Do not weaken it locally.
  • Exported functions and public APIs declare explicit parameter and return types. Local variables may use inference.
  • Use interface for reusable object shapes, type for unions, intersections, and mapped types.
  • Avoid any. When unavoidable, scope it as narrowly as possible and annotate // eslint-disable-next-line @typescript-eslint/no-explicit-any with a one-line reason (see cli.ts:HttpClient for the canonical example).
  • Prefer unknown over any at module boundaries; narrow with type guards.

File structure

  1. Imports first - Node built-ins (path, fs), then third-party (axios, yargs, js-yaml, zod, ini), then local relative imports.
  2. Types and interfaces.
  3. Module-level constants.
  4. Functions and classes.
  5. export last when it improves readability; export class / export function inline is also fine.

Naming

  • Classes - PascalCase (ProfileStore, OpenapiLoader, CommandSearch).
  • Functions and methods - camelCase (loadSpec, buildCommands, selectProfile).
  • Interfaces and type aliases - PascalCase (Profile, CliCommand, HttpClient).
  • Constants - UPPER_SNAKE_CASE for environment-style globals, otherwise meaningful camelCase.
  • Files - kebab-case.ts matching the dominant exported type (profile-store.ts exports ProfileStore).

Error handling

  • Throw Error subclasses with informative messages; never throw strings.
  • At the CLI boundary (cli.ts), catch and translate to a user-friendly message + non-zero exit code. Inner layers should let exceptions propagate.
  • For external input (HTTP responses, parsed YAML/JSON), validate with zod schemas before consuming.

Read the full file on GitHub · 56 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 · 56 lines · 658 tokens per session scan A 205c2acd5e2e

Subscribe to this mod's changes

code-style is a cursor rule published in the GitHub repository EvilFreelancer/openapi-to-cli (256 stars, last pushed 11d ago), licensed MIT. It adds 658 tokens to every session, about $0.0033 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.