Loading...
Loading...
[Review & Quality] Simplifies and refines code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code unless instructed otherwise.
npx skill4agent add duc01226/easyplatform code-simplifier| Step | Action | Key Notes |
|---|---|---|
| 1 | Identify targets | Recent changes via |
| 2 | Analyze complexity | Nesting >3, methods >20 lines, duplicated code, unclear naming |
| 3 | Apply simplifications | One refactoring type at a time; follow platform patterns |
| 4 | Verify | Run related tests, confirm no behavior changes |
.With().PipeIf()PlatformVmStoreuntilDestroyed()/code-simplifier # Simplify recently modified files
/code-simplifier path/to/file.ts # Simplify specific file
/code-simplifier --scope=function # Focus on function-level simplification.claude/skills/shared/anti-hallucination-protocol.mdcode-simplifier:code-simplifierTask(subagent_type="code-simplifier:code-simplifier", prompt="Review and simplify [target files]")| Metric | Threshold | Action |
|---|---|---|
| Nesting depth | > 3 levels | Flatten with guard clauses |
| Method length | > 20 lines | Extract focused methods |
| Duplicated code | 2+ occurrences | Apply DRY, use platform patterns |
| Naming clarity | Unclear intent | Make self-documenting |
Entity.XxxExpr().With().Then().PipeIf()MapToObject()MapToEntity()PlatformValidationResultPlatformVmStoreuntilDestroyed()observerLoadingErrorState()| Action | Description |
|---|---|
| Reduce nesting | Flatten deep if/else chains with guard clauses |
| Extract methods | Break long methods into focused units |
| Simplify conditionals | Use early returns, named booleans |
| Remove duplication | Apply DRY, use platform patterns |
| Improve naming | Make code self-documenting |
git diff --name-only HEAD~1function getData() {
const result = fetchData();
if (result !== null && result !== undefined) {
return result;
} else {
return null;
}
}function getData() {
return fetchData() ?? null;
}User: /code-simplifier src/Domain/Entities/Employee.cs
Claude:
1. Analyzed Employee.cs (145 lines)
2. Found: 2 nested conditionals, 1 duplicated expression
3. Applied:
- Extracted IsActiveInCompanyExpr() static expression
- Replaced nested if with guard clause in Validate()
- Renamed `x` to `employee` in lambda
4. Tests: All passing
5. Complexity reduced: 145 -> 128 lines