home / skills / dyad-sh / dyad / lint

lint skill

/.claude/skills/lint

This skill runs pre-commit checks including formatting, linting, and type-checking, and fixes errors to prepare code for commit.

npx playbooks add skill dyad-sh/dyad --skill lint

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.5 KB
---
name: dyad:lint
description: Run pre-commit checks including formatting, linting, and type-checking, and fix any errors.
---

# Lint

Run pre-commit checks including formatting, linting, and type-checking, and fix any errors.

## Instructions

1. **Run formatting check and fix:**

   ```
   npm run fmt
   ```

   This will automatically fix any formatting issues.

2. **Run linting with auto-fix:**

   ```
   npm run lint:fix
   ```

   This will fix any auto-fixable lint errors.

3. **Fix remaining lint errors manually:**

   If there are lint errors that could not be auto-fixed, read the affected files and fix the errors manually. Common issues include:
   - Unused variables or imports (remove them)
   - Missing return types (add them)
   - Any other ESLint rule violations

4. **Run type-checking:**

   ```
   npm run ts
   ```

5. **Fix any type errors:**

   If there are type errors, read the affected files and fix them. Common issues include:
   - Type mismatches (correct the types)
   - Missing type annotations (add them)
   - Null/undefined handling issues (add appropriate checks)

6. **Re-run all checks to verify:**

   After making manual fixes, re-run the checks to ensure everything passes:

   ```
   npm run fmt && npm run lint && npm run ts
   ```

7. **Summarize the results:**
   - Report which checks passed
   - List any fixes that were made manually
   - If any errors could not be fixed, explain why and ask the user for guidance
   - If all checks pass, confirm the code is ready to commit

Overview

This skill runs the repository's pre-commit checks: formatting, linting (with auto-fix), and TypeScript type-checking, then fixes issues where possible. It automates the standard local validation steps and produces a clear summary of results and any remaining work. Use it before committing or opening a pull request to ensure code quality and consistent style.

How this skill works

The skill executes the project's npm scripts in sequence: formatter (npm run fmt), linter with auto-fix (npm run lint:fix), and the TypeScript checker (npm run ts). It applies automatic fixes, surfaces non-auto-fixable problems for manual correction, and re-runs the full suite to verify all issues are resolved. Finally, it generates a concise report listing passed checks, automated fixes, manual fixes performed, and outstanding errors with guidance.

When to use it

  • Before committing changes or creating a pull request
  • After merging a feature branch to catch regressions
  • When switching branches to ensure local workspace consistency
  • Before running CI to reduce noisy failures
  • During code reviews to validate style and types

Best practices

  • Run npm run fmt first to normalize style and reduce lint noise
  • Run npm run lint:fix to resolve auto-fixable issues before manual edits
  • Address remaining lint errors by removing unused imports/variables and adding missing return types
  • Fix type errors by correcting type annotations and adding null/undefined guards
  • Re-run npm run fmt && npm run lint && npm run ts to confirm a clean bill of health before commit

Example use cases

  • Pre-commit checklist: format, lint auto-fix, run type-check, then commit if all pass
  • CI preflight: locally run the same commands to replicate CI results and reduce pipeline failures
  • Onboarding: teach new contributors the exact commands to make their branches conform to project rules
  • Bug fix validation: ensure a hotfix didn’t introduce type or lint regressions before deployment

FAQ

What if npm run lint:fix doesn't fix everything?

Review the remaining lint errors, open the affected files, and correct issues like unused variables, missing return types, or rule-specific violations. After manual fixes, re-run the checks.

What if type-checking (npm run ts) reports errors I can't resolve?

Inspect the reported files and error messages. Common fixes are adding explicit types, adjusting generics, or adding null/undefined checks. If a type is complex or external, ask for guidance and include the specific error output in your request.