agentleFS
EvilFreelancerEvilFreelancer/openapi-to-cli/.cursor/rules/code-style.mdc

openapi-to-cli / rules

Cursor rule263 starsChanged 3 months agoMITView on GitHub

Code style for openapi-to-cli (TypeScript)

The file

We split this code-style.mdc into the rules it gives an agent

8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All code comments and identifiers in English.

    line 13
  2. Distinctive:

    Default to no comments. Add a comment only when the why is non-obvious (workaround, hidden constraint, subtle invariant).

    line 16
  3. Very specific:

    Use interface for reusable object shapes, type for unions, intersections, and mapped types.

    line 22
  4. Very specific:

    Avoid any. When unavoidable, scope it as narrowly as possible and annotate // eslint-disable-next-line @typescript-eslint/no-explicit-any …

    line 23
  5. Very specific:

    Prefer unknown over any at module boundaries.

    line 24
  6. Very specific:

    Prefer async/await. Avoid .then() chains in new code.

    line 50
  7. Very specific:

    Don't fire-and-forget Promises.

    line 51
  8. Very specific:

    When a module performs I/O, accept the dependency via a constructor option (fs, httpClient, stdout).

    line 55

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
code-style.mdc
---
description: Code style for openapi-to-cli (TypeScript)
globs: **/*.ts
alwaysApply: true
---

# 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.

## Async

- Prefer `async/await`. Avoid `.then()` chains in new code.
- Don't fire-and-forget Promises; always `await` or explicitly handle.

## Testing-facing affordances

When a module performs I/O, accept the dependency via a constructor option (`fs`, `httpClient`, `stdout`). This is how `OpenapiLoader`, `ProfileStore`, and the `run()` entry in `cli.ts` are structured; follow the same pattern in new modules.

Download now (ZIP)

Does it work?

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

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.