openapi-to-cli / rules
Cursor rule263 starsChanged 3 months agoMITView on GitHub
Code style for openapi-to-cli (TypeScript)
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/architecture.mdcCursor rule
- .cursor/rules/implementation-order.mdcCursor rule
- .cursor/rules/testing.mdcCursor rule
- .cursor/rules/workflow.mdcCursor rule
- ocli-apiSkill
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
- Distinctive: line 13
All code comments and identifiers in English.
- Distinctive: line 16
Default to no comments. Add a comment only when the why is non-obvious (workaround, hidden constraint, subtle invariant).
- Very specific: line 22
Use interface for reusable object shapes, type for unions, intersections, and mapped types.
- Very specific: line 23
Avoid any. When unavoidable, scope it as narrowly as possible and annotate // eslint-disable-next-line @typescript-eslint/no-explicit-any …
- Very specific: line 24
Prefer unknown over any at module boundaries.
- Very specific: line 50
Prefer async/await. Avoid .then() chains in new code.
- Very specific: line 51
Don't fire-and-forget Promises.
- Very specific: line 55
When a module performs I/O, accept the dependency via a constructor option (fs, httpClient, stdout).
≈ “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.
Files
--- 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.
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
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.

