Agent Skills › trycompai/comp › cleanup

cleanup

GitHub

强制在代码修改后执行的清理技能,审查变更文件以消除冗余检查、不一致性、死代码和可读性问题,确保代码整洁并符合规范。

.claude/skills/cleanup/SKILL.md trycompai/comp

Trigger Scenarios

完成实现工作后 修复Bug后 重构代码后 提交代码前

Install

npx skills add trycompai/comp --skill cleanup -g -y
More Options

Non-standard path

npx skills add https://github.com/trycompai/comp/tree/main/.claude/skills/cleanup -g -y

Use without installing

npx skills use trycompai/comp@cleanup

指定 Agent (Claude Code)

npx skills add trycompai/comp --skill cleanup -a claude-code -g -y

安装 repo 全部 skill

npx skills add trycompai/comp --all -g -y

预览 repo 内 skill

npx skills add trycompai/comp --list

SKILL.md

Frontmatter
{
    "name": "cleanup",
    "description": "MUST run after writing or modifying code — reviews changed files for verbose patterns, inconsistencies, and readability issues before considering work done"
}

Post-Implementation Cleanup

This skill is mandatory. After writing or modifying code, you MUST review all changed files before reporting the task as complete. Code must be readable at a glance.

When to Run

  • After completing any implementation work
  • After fixing bugs
  • After refactoring
  • Before committing

Checklist

For every file you changed, verify:

1. No Verbose Defensive Checks

Extract repeated patterns into typed helpers.

// ❌ Verbose and repeated
const perms = typeof role.permissions === 'string'
  ? JSON.parse(role.permissions) : role.permissions;
if (perms && typeof perms === 'object' && Array.isArray(perms.portal) && perms.portal.length > 0) {

// ✅ Typed helper
const perms = parseRolePermissions(role.permissions);
if (perms?.portal?.length) {

2. Consistent Idioms Across Files

The same check must use the same pattern everywhere.

// ❌ Inconsistent
file1: perms?.portal?.length > 0
file2: perms?.portal?.length

// ✅ Pick one
perms?.portal?.length

3. No Redundant Type Casts

If you need a cast to satisfy TypeScript, extract a helper function instead.

// ❌ Verbose cast repeated in every file
const restrictedRoles: readonly string[] = RESTRICTED_ROLES;
restrictedRoles.includes(role);

// ✅ Helper in shared package
export function isRestrictedRole(role: string): boolean {
  return (RESTRICTED_ROLES as readonly string[]).includes(role);
}

4. Error Handling on Boundaries

JSON.parse, external API calls, and DB queries at system boundaries need error handling.

// ❌ Unguarded parse
const parsed = JSON.parse(value);

// ✅ Safe parse
try {
  return JSON.parse(value);
} catch {
  return null;
}

5. Shared Patterns Belong in Shared Packages

If the same logic appears in 2+ apps (api, app, portal), extract it to a shared package (packages/auth, packages/db, etc.).

6. No Dead Code

  • Remove unused imports
  • Remove unused variables
  • Remove unused function parameters
  • Remove props that are always null/false

7. Readable at a Glance

  • Function and variable names should convey intent without reading the implementation
  • One-liner expressions over multi-line when equally clear
  • No nested ternaries

How to Run

  1. List all files you modified: git diff --name-only
  2. Read each file and check against this checklist
  3. Fix any issues found
  4. Typecheck after fixes: npx tsc --noEmit

Version History

  • 0ccfcc2 Current 2026-09-27 10:23

Same Skill Collection

.agents/skills/audit-design-system/SKILL.md
.agents/skills/audit-hooks/SKILL.md
.agents/skills/audit-rbac/SKILL.md
.agents/skills/audit-tests/SKILL.md
.agents/skills/better-auth-best-practices/SKILL.md
.agents/skills/billing/SKILL.md
.agents/skills/code/SKILL.md
.agents/skills/cursor-usage/SKILL.md
.agents/skills/data/SKILL.md
.agents/skills/diagnose-generation-failure/SKILL.md
.agents/skills/forms/SKILL.md
.agents/skills/generate-mcp-server/SKILL.md
.agents/skills/infra/SKILL.md
.agents/skills/manage-openapi-overlays/SKILL.md
.agents/skills/new-feature-setup/SKILL.md
.agents/skills/production-readiness/SKILL.md
.agents/skills/prompt-engineering/SKILL.md
.agents/skills/speakeasy-context/SKILL.md
.agents/skills/stale-worktree-cleanup/SKILL.md
.agents/skills/trigger-advanced-tasks/SKILL.md
.agents/skills/trigger-basic/SKILL.md
.agents/skills/trigger-config/SKILL.md
.agents/skills/trigger-realtime/SKILL.md
.agents/skills/ui/SKILL.md
.claude/skills/api-endpoint-contract/SKILL.md
.claude/skills/audit-design-system/SKILL.md
.claude/skills/audit-hooks/SKILL.md
.claude/skills/audit-rbac/SKILL.md
.claude/skills/audit-tests/SKILL.md
.claude/skills/check-results-service/SKILL.md
.claude/skills/code/SKILL.md
.claude/skills/cursor-usage/SKILL.md
.claude/skills/data/SKILL.md
.claude/skills/forms/SKILL.md
.claude/skills/infra/SKILL.md
.claude/skills/new-feature-setup/SKILL.md
.claude/skills/production-readiness/SKILL.md
.claude/skills/prompt-engineering/SKILL.md
.claude/skills/security-review/SKILL.md
.claude/skills/stale-worktree-cleanup/SKILL.md
.claude/skills/trigger-advanced-tasks/SKILL.md
.claude/skills/trigger-basic/SKILL.md
.claude/skills/trigger-config/SKILL.md
.claude/skills/trigger-realtime/SKILL.md
.claude/skills/ui/SKILL.md
.agents/skills/essentials/SKILL.md
.agents/skills/prisma/SKILL.md
.agents/skills/trigger-scheduled-tasks/SKILL.md
.claude/skills/essentials/SKILL.md

Metadata

Files
0
Version
0ccfcc2
Hash
0f3a5e01
Indexed
2026-09-27 10:23

Home - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-28 08:39
浙ICP备14020137号-1