fix: add agent and skill

This commit is contained in:
imeepos
2026-01-21 11:15:08 +08:00
parent 8c43b9daf0
commit 5a28a0e85e
50 changed files with 7237 additions and 0 deletions

69
.claude/commands/coder.md Normal file
View File

@@ -0,0 +1,69 @@
## Core Philosophy
**存在即合理 (Existence Implies Necessity)**
- Every class, property, method, function, and file must have an irreplaceable reason to exist
- Every line of code serves a unique, essential purpose
- Ruthlessly eliminate any meaningless or redundant code
- Before adding anything, ask: "Is this absolutely necessary? Does it serve an irreplaceable purpose?"
- If something can be removed without loss of functionality or clarity, it must be removed
- 注意:不要过度设计!
**优雅即简约 (Elegance is Simplicity)**
- Never write meaningless comments—the code itself tells its story
- Code should be self-documenting through thoughtful structure and naming
- Reject redundant functionality—every design element is meticulously crafted
- Variable and function names are poetry: `useSession` is not just an identifier, it's the beginning of a narrative
- Names should reveal intent, tell stories, and guide readers through the code's journey
- Favor clarity and expressiveness over brevity when naming
- 注意:不要过度设计!
**性能即艺术 (Performance is Art)**
- Optimize not just for speed, but for elegance in execution
- Performance improvements should enhance, not compromise, code beauty
- Seek algorithmic elegance—the most efficient solution is often the most beautiful
- Balance performance with maintainability and clarity
- 注意:不要过度设计!
**错误处理如为人处世的哲学 (Error Handling as Life Philosophy)**
- Every error is an opportunity for refinement and growth
- Handle errors gracefully, with dignity and purpose
- Error messages should guide and educate, not merely report
- Use errors as signals for architectural improvement
- Design error handling that makes the system more resilient and elegant
- 注意:不要过度设计!
**日志是思想的表达 (Logs Express Thought)**
- Logs should narrate the system's story, not clutter it
- Each log entry serves a purpose: debugging, monitoring, or understanding system behavior
- Log messages should be meaningful, contextual, and actionable
- Avoid verbose logging—only capture what matters
- 注意:不要过度设计!
## Your Approach
When writing code:
1. Begin with deep contemplation of the problem's essence
2. Design the minimal, most elegant solution
3. Choose names that tell stories and reveal intent
4. Write code that reads like prose—clear, purposeful, flowing
5. Eliminate every unnecessary element
6. Ensure every abstraction earns its place
7. Optimize for both human understanding and machine performance
When reviewing code:
1. Identify redundancies and unnecessary complexity
2. Question the existence of every element: "Why does this exist?"
3. Suggest more elegant, minimal alternatives
4. Evaluate naming: Does it tell a story? Does it reveal intent?
5. Assess error handling: Is it philosophical and purposeful?
6. Review logs: Do they express meaningful thoughts?
7. Provide refactoring suggestions that elevate code to art
## Quality Standards
- **Necessity**: Can this be removed? If yes, remove it.
- **Clarity**: Does the code explain itself? If it needs comments to be understood, refactor it.
- **Elegance**: Is this the simplest, most beautiful solution?
- **Performance**: Is this efficient without sacrificing clarity?
- **Purpose**: Does every element serve an irreplaceable function?

View File

@@ -0,0 +1,211 @@
---
description: Fix all ESLint errors by modifying code to comply with eslint.config.js rules
argument-hint: specific files or patterns to lint
---
# Lint Fix
## User Arguments
User can provide specific files or patterns to focus on:
```
$ARGUMENTS
```
If nothing is provided, lint all applicable files in the project.
## Context
ESLint helps maintain code quality and consistency by enforcing coding standards defined in `eslint.config.js`. This command systematically fixes all ESLint errors by modifying the code to comply with the configured rules.
## Goal
Fix all ESLint errors and warnings to achieve a clean linting result.
## Important Constraints
- **NEVER modify eslint.config.js** - the rules are fixed and must not be changed
- **Fix the code, not the rules** - modify code to comply with the linting rules
- **Analyze complexity of changes** -
- If there are 2 or more files with errors, or one file with complex/many errors, then **Do not fix yourself** - only orchestrate agents!
- If there is only one file with simple/minor errors, then you can fix it yourself.
## Key ESLint Rules (from eslint.config.js)
**Type Safety Rules:**
- `@typescript-eslint/no-explicit-any`: error - Ban `any` type
- `@typescript-eslint/no-non-null-assertion`: error - Ban ! non-null assertions
- `@typescript-eslint/no-unsafe-assignment`: error - Ban unsafe type assignments
- `@typescript-eslint/no-unsafe-call`: error - Ban unsafe function calls
- `@typescript-eslint/no-unsafe-member-access`: error - Ban unsafe property access
- `@typescript-eslint/no-unsafe-return`: error - Ban unsafe returns
- `@typescript-eslint/no-unsafe-argument`: error - Ban unsafe arguments
**Code Quality Rules:**
- `@typescript-eslint/no-unused-vars`: error - Unused variables (prefix with `_` to ignore)
- `@typescript-eslint/no-floating-promises`: error - Unhandled promises
- `@typescript-eslint/no-misused-promises`: error - Misused async operations
- `@typescript-eslint/strict-boolean-expressions`: error - Strict boolean checks
- `@typescript-eslint/prefer-nullish-coalescing`: error - Use `??` instead of `||`
- `@typescript-eslint/prefer-optional-chain`: error - Use `?.` instead of `&&` checks
## Workflow Steps
### Preparation
1. **Read sadd skill if available**
- If available, read the sadd skill to understand best practices for managing agents
2. **Discover linting infrastructure**
- Read @README.md and package.json
- Identify the lint command (usually `npm run lint` or `pnpm lint`)
- Check if `eslint.config.js` exists (it should not be modified)
3. **Run ESLint**
- Execute the lint command to see all errors
- If user provided arguments, run: `eslint $ARGUMENTS`
- Otherwise run the project's full lint command
4. **Identify files with errors**
- Parse ESLint output to get list of files with errors
- Group by file for parallel agent execution
### Analysis
5. **Verify single file linting**
- Launch haiku agent to find proper command to lint a single file
- Test: `eslint path/to/file.ts`
- This ensures agents can lint files in isolation
### Lint Fixing
#### Simple Single File Flow
If there is only one file with simple/minor errors, you can fix it yourself:
1. Read the file with errors
2. Understand each ESLint error
3. Fix each error systematically:
- Replace any with proper types
- Remove ! assertions and use proper type guards
- Fix unsafe operations with proper type checking
- Remove unused variables or prefix with _
- Use ?? instead of || for null checks
- Use ?. instead of && for optional chaining
4. Re-run the lint command
5. Iterate until all errors are fixed
#### Multiple Files or Complex File Flow
If there are multiple files with errors, or one file with many/complex errors, use specialized agents:
6. **Launch developer agents (parallel)** (Sonnet or Opus models)
- Launch one agent per file with lint errors
- Provide each agent with:
* **Context**: ESLint errors for this file
* **Target**: Which specific file to fix
* **Rules**: Reference eslint.config.js for the rules (DO NOT modify it)
* **Constraint**: Fix code to comply with rules, never modify eslint.config.js
* **Goal**: Iterate until file has no ESLint errors
7. **Verify all fixes**
- After all agents complete, run full lint command again
- Verify all files pass
8. **Iterate if needed**
- If any files still have errors: Return to step 5
- Launch new agents only for remaining errors
- Continue until 100% pass rate
## Success Criteria
- All ESLint errors fixed ✅
- All ESLint warnings fixed (or justified) ✅
- Code complies with eslint.config.js rules ✅
- eslint.config.js remains unchanged ✅
## Agent Instructions Template
When launching agents, use this template:
```
The file {FILE_PATH} has ESLint errors that need to be fixed.
ESLint errors:
{ESLINT_OUTPUT}
Your task:
1. Read the file {FILE_PATH}
2. Read eslint.config.js to understand the rules (DO NOT modify it)
3. Fix each ESLint error by modifying the code, not the rules:
- Replace `any` with proper types or `unknown` where appropriate
- Remove ! non-null assertions; use type guards or optional chaining
- Fix unsafe type operations with proper type checking
- Remove unused variables or prefix with _
- Use ?? (nullish coalescing) instead of ||
- Use ?. (optional chaining) instead of && checks
- Handle promises properly with await or .catch()
- Use strict boolean expressions (no loose truthy checks)
4. Run: eslint {FILE_PATH}
5. Iterate until all ESLint errors are fixed
IMPORTANT: Never modify eslint.config.js - the rules are fixed.
```
## Common ESLint Error Fixes
**@typescript-eslint/no-explicit-any**
```typescript
// Bad
function foo(x: any) { return x; }
// Good
function foo<T>(x: T): T { return x; }
// or
function foo(x: unknown) { /* validate and use */ }
```
**@typescript-eslint/no-non-null-assertion**
```typescript
// Bad
const value = maybeNull!.toString();
// Good
const value = maybeNull?.toString();
// or
if (maybeNull !== null) {
const value = maybeNull.toString();
}
```
**@typescript-eslint/prefer-nullish-coalescing**
```typescript
// Bad
const value = input || 'default';
// Good
const value = input ?? 'default';
```
**@typescript-eslint/prefer-optional-chain**
```typescript
// Bad
if (obj && obj.nested && obj.nested.value) { }
// Good
if (obj?.nested?.value) { }
```
**@typescript-eslint/no-unused-vars**
```typescript
// Bad
function foo(a: number, b: number) {
return a;
}
// Good
function foo(a: number, _b: number) {
return a;
}
```

View File

@@ -0,0 +1 @@
use .claude\skills\writing-plans\SKILL.md skill