agent-skills / accelint-ts-best-practices
AGENTS.md25 starsChanged 54 days agoApache-2.0View on GitHub
Comprehensive coding standards for JavaScript and TypeScript applications, designed for AI agents and LLMs. This guide focuses on code correctness, type safety, and defensive programming. Each rule includes one-line summaries here, with links to detailed examples in the references/ folder. Load reference files only when you need detailed implementation guidance for a specific rule. Note: For performance optimization tasks, use the accelint-ts-performance skill instead. For documentation tasks, use the accelint-ts-documentation skill. This structure minimizes context usage while providing complete implementation…
We split this AGENTS.md into the rules it gives an agent
26 rules. About 0 are common, 15 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈15
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 24
MANDATORY: Read quick-start.md for complete workflow examples
- Distinctive: line 26
Start with the pattern, then check related safety rules
- Distinctive: line 29
Start with the rule summaries below to identify anti-patterns
- Distinctive: line 31
Do NOT load all references at once: - use progressive loading
- Very specific: line 34
Read any.md if encountering any types
- Very specific: line 35
Read enums.md if replacing enum
- Distinctive: line 36
Read type-vs-interface.md for declaration choices
- Distinctive: line 39
MANDATORY: Read input-validation.md for external data
- Distinctive: line 40
Read bounded-iteration.md for any loops or queues
- Distinctive: line 41
Read error-handling.md for proper error patterns
- Distinctive: line 49
NEVER: do these - they appear in codebases frequently but significantly degrade code quality, safety, or maintainability:
- Very specific: line 51
NEVER: use any type - use unknown for truly unknown types or generics for flexible types
- Very specific: line 52
NEVER: use enum keyword - use as const objects to avoid extra JavaScript output and runtime overhead
- Very specific: line 53
NEVER: use interface for simple type aliases - use type instead.
- Distinctive: line 56
NEVER: create unbounded loops or queues - set explicit limits to prevent runaway resource consumption and crashes
- Very specific: line 69
Keep functions under 50 lines.
- Very specific: line 73
Always use block style { } for control flow (prevents bugs when adding code).
- Very specific: line 77
Use const to signal immutability.
- Distinctive: line 85
Use Linux line endings; employ defensive programming.
- Very specific: line 97
Never use any (disables type checking and propagates through codebase).
- Very specific: line 101
Never use enum (generates 5+ lines of runtime code per enum).
- Very specific: line 105
Prefer type over interface.
- Distinctive: line 109
Use statically analyzable paths for imports and file-system operations.
- Distinctive: line 117
Always validate and sanitize external data at system boundaries with schemas.
- Distinctive: line 121
Use assertions to detect programmer errors.
- Distinctive: line 133
Never create unbounded loops, queues, or recursive calls.
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md 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
JavaScript and TypeScript Best Practices
Abstract
Comprehensive coding standards for JavaScript and TypeScript applications, designed for AI agents and LLMs. This guide focuses on code correctness, type safety, and defensive programming. Each rule includes one-line summaries here, with links to detailed examples in the references/ folder. Load reference files only when you need detailed implementation guidance for a specific rule.
Note: For performance optimization tasks, use the accelint-ts-performance skill instead. For documentation tasks, use the accelint-ts-documentation skill.
How to Use This Guide
- Start here: Scan the rule summaries to identify relevant patterns
- Load references as needed: Click through to detailed examples only when implementing
- Progressive loading: Each reference file is self-contained with ❌/✅ examples
This structure minimizes context usage while providing complete implementation guidance when needed.
Loading Strategy
When writing new code:
- MANDATORY: Read quick-start.md for complete workflow examples
- Load specific pattern files only as you encounter relevant scenarios
- Start with the pattern, then check related safety rules
When reviewing existing code:
- Start with the rule summaries below to identify anti-patterns
- Load corresponding reference files for detailed fixes
- Do NOT load all references at once - use progressive loading
When fixing type errors:
- Read any.md if encountering
anytypes - Read enums.md if replacing
enum - Read type-vs-interface.md for declaration choices
When implementing safety features:
- MANDATORY: Read input-validation.md for external data
- Read bounded-iteration.md for any loops or queues
- Read error-handling.md for proper error patterns
General rule: Load reference files on-demand based on the specific pattern you're implementing. Each reference is self-contained with ❌/✅ examples.
Critical Anti-Patterns
NEVER do these - they appear in codebases frequently but significantly degrade code quality, safety, or maintainability:
- NEVER use
anytype - useunknownfor truly unknown types or generics for flexible types - NEVER use
enumkeyword - useas constobjects to avoid extra JavaScript output and runtime overhead - NEVER use
interfacefor simple type aliases - usetypeinstead; reserveinterfaceonly for declaration merging or legacy API compatibility - NEVER mutate function parameters - creates hidden side effects and breaks pure function principles
- NEVER return
nullorundefined- return zero values instead ([], {}, 0, "") to eliminate downstream null checks - NEVER create unbounded loops or queues - set explicit limits to prevent runaway resource consumption and crashes
See individual reference files for detailed alternatives and ✅ correct patterns.
1. General Best Practices
1.1 Naming Conventions
Append qualifiers in descending order (latencyMsMax not maxLatencyMs) to enable autocomplete grouping; prefix booleans with is/has.
View detailed examples
1.2 Functions
Keep functions under 50 lines; explicitly type return values; avoid defaults; use function keyword for pure functions.
View detailed examples
1.3 Control Flow
Always use block style { } for control flow (prevents bugs when adding code); use early returns for guard clauses.
View detailed examples
1.4 State Management
Use const to signal immutability; never mutate function parameters (creates hidden side effects); keep leaf functions pure for testability.
View detailed examples
1.5 Return Values
Return zero values ([], {}, 0, '') instead of null/undefined to eliminate defensive null checks and enable method chaining and composition. View detailed examples
1.6 Misc
Use Linux line endings; employ defensive programming; aim for zero technical debt. View detailed examples
1.7 Code Duplication (DRY Principle)
Extract common patterns into utility functions; consolidate duplicated logic; apply DRY when abstraction reduces complexity. View detailed examples
2. TypeScript
2.1 Any
Never use any (disables type checking and propagates through codebase); use unknown to force validation or generics to preserve types.
View detailed examples
2.2 Enums
Never use enum (generates 5+ lines of runtime code per enum); use as const objects for zero-cost type-safe constants.
View detailed examples
2.3 Type vs. Interface
Prefer type over interface; use interface only for declaration merging or class contracts.
View detailed examples
2.4 Bundler-Friendly Paths
Use statically analyzable paths for imports and file-system operations; avoid dynamic path composition that prevents build-time analysis. View detailed examples
3. Safety
3.1 Input Validation
Always validate and sanitize external data at system boundaries with schemas. View detailed examples
3.2 Assertions
Use assertions to detect programmer errors; split compound assertions; include values. View detailed examples
3.3 Error Handling
Handle all errors explicitly; use Result types or try-catch blocks; never swallow errors silently. View detailed examples
3.4 Error Messages
Make user errors empathetic and actionable; make developer errors specific with values. View detailed examples
3.5 Bounded Iteration
Never create unbounded loops, queues, or recursive calls; set explicit limits to prevent runaway resource consumption and system crashes. View detailed examples
4. Performance
For performance optimization tasks, use the accelint-ts-performance skill instead. It provides:
- 4-phase workflow (Profile → Analyze → Optimize → Verify)
- Comprehensive optimization patterns for all performance categories
- Profiling tool guidance (Chrome DevTools, Node.js --prof)
- Bottleneck categorization and decision frameworks
5. Documentation
For documentation-specific tasks, use the accelint-ts-documentation skill instead. It provides comprehensive guidance for JSDoc comments, comment markers, and code comment quality.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 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 repository49 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/accelint-design-foundation/AGENTS.mdAGENTS.md
- skills/accelint-eval-architect/AGENTS.mdAGENTS.md
- skills/accelint-nextjs-best-practices/AGENTS.mdAGENTS.md
- skills/accelint-prompt-manager/AGENTS.mdAGENTS.md
- skills/accelint-react-best-practices/AGENTS.mdAGENTS.md
- skills/accelint-react-testing/AGENTS.mdAGENTS.md
- skills/accelint-readme-writer/AGENTS.mdAGENTS.md
- skills/accelint-security-best-practices/AGENTS.mdAGENTS.md
- skills/accelint-skill-manager/AGENTS.mdAGENTS.md
- skills/accelint-skill-manager/references/agents.mdAGENTS.md
- skills/accelint-ts-documentation/AGENTS.mdAGENTS.md
- skills/accelint-ts-performance/AGENTS.mdAGENTS.md
- skills/accelint-ts-testing/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- accelint-ac-to-playwrightSkill
- accelint-architecture-docSkill
- accelint-archive-synthesisSkill
- accelint-design-foundationSkill
- accelint-english-managerSkill
- accelint-eval-architectSkill
- accelint-nextjs-best-practicesSkill
- accelint-onboard-agentsSkill
- accelint-onboard-openspecSkill
- accelint-persona-reviewSkill
- accelint-prompt-managerSkill
- accelint-qrspi-applySkill
- accelint-qrspi-archiveSkill
- accelint-qrspi-proposeSkill
- accelint-react-best-practicesSkill
- accelint-react-testingSkill
- accelint-readme-writerSkill
- accelint-security-best-practicesSkill
- referencesSkill
- accelint-skill-managerSkill
- accelint-skill-proseSkill
- accelint-tanstack-query-best-practicesSkill
- accelint-ts-audit-allSkill
- accelint-ts-best-practicesSkill
- accelint-ts-documentationSkill
- accelint-ts-performanceSkill
- accelint-ts-testingSkill
- constraints-extractorSkill
- context-driftSkill
- epistemic-mapperSkill
- generate-docsSkill
- jargon-extractorSkill
- pr-descriptionSkill
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.

