with one click
cleanup
// MUST run after writing or modifying code — reviews changed files for verbose patterns, inconsistencies, and readability issues before considering work done
// MUST run after writing or modifying code — reviews changed files for verbose patterns, inconsistencies, and readability issues before considering work done
| name | cleanup |
| description | MUST run after writing or modifying code — reviews changed files for verbose patterns, inconsistencies, and readability issues before considering work done |
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.
For every file you changed, verify:
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) {
The same check must use the same pattern everywhere.
// ❌ Inconsistent
file1: perms?.portal?.length > 0
file2: perms?.portal?.length
// ✅ Pick one
perms?.portal?.length
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);
}
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;
}
If the same logic appears in 2+ apps (api, app, portal), extract it to a shared package (packages/auth, packages/db, etc.).
git diff --name-onlynpx tsc --noEmitThe contract every new or modified API endpoint must follow so it is correct for the public OpenAPI spec, the MCP server (npm @trycompai/mcp-server), the ValidationPipe, and the docs. Triggers on "new endpoint", "add API", "new DTO", "@Body", "@RequirePermission", "MCP tool", "edit controller in apps/api", "OpenAPI", or whenever editing controllers under apps/api/src/.
Use when changing Comp AI billing, Stripe products/prices, subscription checkout, org payment methods, entitlements, usage ledgers, invoices, or billing webhooks.
Audit & fix design system usage — migrate @trycompai/ui and lucide-react to @trycompai/design-system
Audit & fix hooks and API usage patterns — eliminate server actions, raw fetch, and stale patterns
Audit & fix RBAC and audit log compliance in API endpoints and frontend components
Audit & fix unit tests for permission-gated components