aif-best-practices

Provides code quality guidelines covering naming, structure, error handling, testing, and review.

31|2|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/letuhao/lore-weave --skill aif-best-practices-letuhao
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: aif-best-practices
Source: https://github.com/letuhao/lore-weave/tree/main/.cursor/skills/aif-best-practices
Command: npx skills add https://github.com/letuhao/lore-weave --skill aif-best-practices-letuhao

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers often write inconsistent code with unclear naming, oversized functions, swallowed errors, and weak tests, leading to unmaintainable codebases and unproductive code reviews. This Skill supplies a universal, language-agnostic set of code quality guidelines that can be applied when writing, reviewing, or refactoring code. ## Core Features & Use Cases - Naming and Structure Guidelines: Concrete good/bad examples for variables, functions, files, directories, and module organization across TypeScript, PHP, Python, and other languages. - Error Handling and Testing Standards: Rules for specific error classes, meaningful messages, AAA test structure, and coverage priorities. - Code Review Checklists: Ready-to-use checklists for authors and reviewers, plus guidance on writing constructive review comments. - Use Case: When refactoring a legacy module, ask for the structure and error-handling guidelines to reorganize functions into single-responsibility units with proper exception types. ## Quick Start Ask the AI to review this function against best practices for naming, error handling, and testing.

Frequently Asked Questions about aif-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I improve naming conventions in my code?

Use descriptive names that reveal intent, avoid abbreviations except universal ones like id or url, and prefix booleans with is, has, can, or should. Functions should follow a verb-plus-noun pattern such as fetchUser or validateInput, with constants in SCREAMING_SNAKE_CASE.

What are best practices for error handling in TypeScript?

Create specific error classes for domain errors, such as a UserNotFoundError that includes the user ID in its message. Never swallow exceptions with empty catch blocks, and always log errors with context like user IDs or request IDs.

How long should a function be according to clean code guidelines?

Functions should follow single responsibility with one job each, staying within roughly 20 to 30 lines and accepting at most 3 to 4 parameters. Use early returns for guard clauses and avoid side effects in pure functions.

What is the AAA pattern in unit testing?

AAA stands for Arrange, Act, Assert: set up test data, execute the function under test, then verify the result. Each test should check one behavior concept and use a descriptive name following the pattern 'should [expected behavior] when [condition]'.

What should a code review checklist include?

A reviewer checklist should cover correctness, edge cases, security, performance, readability, test coverage, and consistency with project conventions. Authors should self-review the diff, ensure tests pass, and remove debug code before requesting review.

When should project-specific rules override general best practices?

Project-specific rules from a skill-context file take priority when they conflict with general guidelines, since they reflect conventions proven in the actual codebase. When there is no conflict, both general and project rules apply together.