agentsclimarketplace

Clean code

Skill navraj007in/architecture-cowork-plugin/skills/clean-code

Structural code quality rules applied at write time (implementer, scaffolder) and check time (reviewer). Covers function length, single responsibility, abstraction levels, meaningful naming, magic values, parameter design, boolean traps, DRY, dead code, premature abstraction, frontend component decomposition, null safety, async safety, input validation at boundaries, and concurrency safety.From its SKILL.md

Install
npx -y skills add navraj007in/architecture-cowork-plugin --skill clean-code

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

14.2 KB, as published. Nobody here has run it

Clean Code Skill

Structural quality rules for writing and reviewing code within the Archon plugin. These rules are cross-runtime principles with runtime-specific thresholds captured in tables within each sub-file.

What this skill covers

Rule IDNameSub-file
CC-S1Function lengthstructure.md
CC-S2Single responsibilitystructure.md
CC-S3Abstraction levelsstructure.md
CC-N1Meaningful namesnaming.md
CC-N2Magic valuesnaming.md
CC-I1Parameter countinterface.md
CC-I2Boolean trapinterface.md
CC-H1DRYhygiene.md
CC-H2Dead codehygiene.md
CC-H3Premature abstractionhygiene.md
CC-F1Component sizefrontend.md
CC-F2Props interfacefrontend.md
CC-F3Logic extractionfrontend.md
CC-NS1No unguarded nullable accessnull-safety.md
CC-NS2No non-null assertionnull-safety.md
CC-NS3Declare nullable return typesnull-safety.md
CC-NS4Guard collection accessnull-safety.md
CC-NS5Validate external data before usenull-safety.md
CC-NS6Propagate null, do not swallownull-safety.md
CC-AS1Every promise must be awaitedasync-safety.md
CC-AS2Do not mix async stylesasync-safety.md
CC-AS3Async errors must propagateasync-safety.md
CC-AS4No parallel state mutationasync-safety.md
CC-AS5Timeout on all external async callsasync-safety.md
CC-IV1Validate request body before useinput-validation.md
CC-IV2Validate path and query paramsinput-validation.md
CC-IV3Sanitise string inputsinput-validation.md
CC-IV4Validate env vars at startupinput-validation.md
CC-IV5Reject unknown fieldsinput-validation.md
CC-CS1No mutable loop variable captureconcurrency-safety.md
CC-CS2Correct React state update patternconcurrency-safety.md
CC-CS3Module-level singletons must be concurrency-safeconcurrency-safety.md
CC-CS4No non-atomic paired readsconcurrency-safety.md
CC-CS5Idempotency keys for state-mutating opsconcurrency-safety.md

What this skill does NOT cover

These concerns are owned by other skills/commands — do not duplicate:

  • Logging patterns → skills/production-hardening/
  • Error handling, retry, timeout → skills/production-hardening/
  • Auth patterns → skills/production-hardening/
  • Import style, naming case (camelCase vs snake_case) → pattern fingerprint
  • Cyclomatic complexity scoring → /architect:complexity-check
  • Security vulnerabilities → /architect:review Check 3, /architect:security-scan
  • Architecture layer violations (logic in route, cross-component imports) → /architect:review Check 5

Severity Table

RuleSeverityRationale
CC-S1 function lengthWARNINGStructure debt — not immediately broken
CC-S2 single responsibilityWARNINGSame class of issue as CC-S1
CC-S3 abstraction levelsSUGGESTSubtle and context-dependent
CC-N1 meaningful namesWARNINGGeneric names accumulate into readability debt across the codebase
CC-N2 magic valuesWARNINGUnexplained literals create silent maintenance hazards
CC-I1 parameter countWARNINGDesign smell — signals a missing abstraction
CC-I2 boolean trapSUGGESTUnreadable at call site but logic is correct
CC-H1 DRYSUGGEST at 2 occurrences / WARNING at 3+Reviewer must count before assigning
CC-H2 dead codeWARNINGMisleads readers, pollutes git blame
CC-H3 premature abstractionWARNINGDirectly violates CLAUDE.md: "Don't create helpers for one-time operations"
CC-F1 component sizeWARNINGMonolithic components block reuse and testing
CC-F2 props interfaceWARNINGOver-coupled components indicate decomposition is needed
CC-F3 logic extractionSUGGESTLogic in render functions works but is harder to test
CC-NS1 unguarded nullable accessBLOCKERDirectly causes TypeError/AttributeError/nil pointer dereference in production
CC-NS2 non-null assertionWARNINGBypasses the type system — generated code must not use it
CC-NS3 undeclared nullable returnWARNINGCallers cannot write safe code against undeclared nullable returns
CC-NS4 unguarded collection accessBLOCKERIndex out of bounds / undefined on empty collections crashes in production
CC-NS5 unvalidated external dataBLOCKERMalformed external data causes crashes or silent data corruption
CC-NS6 null swallowed in serviceWARNINGHides absence from caller — leads to wrong-data bugs
CC-AS1 unawaited promiseBLOCKERSilent failure — errors swallowed and operations silently skip
CC-AS2 mixed async stylesWARNINGConfusing control flow and inconsistent error propagation
CC-AS3 async error swallowedBLOCKERCaller cannot detect failure — same production impact as CR-E1
CC-AS4 parallel state mutationWARNINGNon-deterministic results; data races in non-JS runtimes
CC-AS5 no timeout on external callWARNINGHangs indefinitely under network partition or slow dependency
CC-IV1 unvalidated request bodyBLOCKERType confusion, panics, or injection when unvalidated fields reach DB or logic
CC-IV2 unvalidated path/query paramsBLOCKERType coercion failures, invalid DB queries, injection via malformed IDs
CC-IV3 unsanitised string inputsWARNINGLength violations cause DB errors; unsanitised HTML output is XSS
CC-IV4 unvalidated env varsWARNINGConfig errors surface at runtime, not at startup
CC-IV5 unknown fields passed throughWARNINGMass-assignment risk — escalates to BLOCKER if ORM binds the full body
CC-CS1 mutable loop variable captureBLOCKERAll closures reference the same final value — silent logic error
CC-CS2 stale closure in React stateWARNINGNon-deterministic state updates under rapid interaction
CC-CS3 unprotected shared mutable stateWARNINGSafe in Node.js but data race in Go/.NET/Python threaded contexts
CC-CS4 non-atomic paired readsWARNINGTOCTOU window — accept or mitigate with a single atomic query
CC-CS5 non-idempotent mutationWARNINGDuplicate charges/records under retry — escalates to BLOCKER for payments

BLOCKERs in this skill: CC-NS1, CC-NS4, CC-NS5, CC-AS1, CC-AS3, CC-IV1, CC-IV2, CC-CS1. These are safety rules that cause runtime crashes or silent failures — not style issues.


Implementer Read Protocol

Read SKILL.md (this file) once at the start of the write session to get the severity table and sub-file map. Then read only the sub-files relevant to the layer you are about to write.

Apply rules as design constraints during writing — not as post-hoc detectors. Fix before moving to the next function.

LayerSub-files to readKey rules
Schema / validationnaming.md + interface.md + null-safety.md + input-validation.mdCC-N1, CC-N2, CC-I1, CC-NS3, CC-NS5, CC-IV3, CC-IV5
Service layerstructure.md + naming.md + interface.md + hygiene.md + null-safety.md + async-safety.mdAll backend rules + all NS + AS rules
Route / controllerstructure.md + interface.md + null-safety.md + input-validation.mdCC-S1, CC-S2, CC-I2, CC-NS1, CC-NS4, CC-IV1, CC-IV2, CC-IV3, CC-IV5
Integration libnaming.md + hygiene.md + null-safety.md + async-safety.mdCC-N1, CC-H3, CC-NS1, CC-NS5, CC-AS1, CC-AS5
Test layerhygiene.mdCC-H1, CC-H2
Frontend componentfrontend.md + naming.md + null-safety.md + concurrency-safety.mdCC-F1, CC-F2, CC-F3, CC-N1, CC-NS1, CC-NS4, CC-CS1, CC-CS2
Config / startupinput-validation.mdCC-IV4

During writing — apply in this order:

  1. Before writing a function signature: apply CC-I1 (parameter count), CC-N1 (naming), and CC-NS3 (declare nullable return type if the function can return null/undefined/None).
  2. For route handlers: apply CC-IV1 and CC-IV2 — write the schema parse as the first statement before any field access.
  3. After every call to a DB query, external API, or collection lookup: apply CC-NS1 (null guard) and CC-NS4 (collection guard) — place the guard immediately before any property access.
  4. After every async function call: apply CC-AS1 — ensure await is present or the Promise is explicitly returned/handled.
  5. After writing the function body: apply CC-S1 (length). Decompose before continuing if over threshold.
  6. After writing a file: apply CC-H2 (dead code) and CC-H3 (premature abstraction).
  7. When copying a logic block: apply CC-H1 (DRY) — extract before copying a second time.
  8. For frontend files: apply CC-F1 (component size) before writing JSX return; apply CC-CS2 for any setState that depends on previous state.
  9. For loop bodies with closures or goroutines: apply CC-CS1 — verify the loop variable is correctly bound.
  10. Whenever consuming external data (API response, env var, IPC payload, DB row): apply CC-NS5 and CC-IV1 — validate shape before accessing fields.

Scaffolder Read Protocol

The scaffolder reads naming.md + hygiene.md + null-safety.md + async-safety.md + input-validation.md + concurrency-safety.md before generating any file.

RuleAppliesNote
CC-N1 meaningful namesYesTemplate names become the codebase baseline
CC-N2 magic valuesYesNo hardcoded ports/timeouts/limits in generated files
CC-H2 dead codeYes — criticalNo TODOs, no commented-out blocks in generated scaffold files
CC-H3 premature abstractionYes — criticalDo not generate single-use utility wrappers
CC-S1 function lengthYesTemplate functions should not be monolithic
CC-H1 DRYPartial3+ occurrences rule only — scaffold legitimately repeats patterns
CC-NS1 unguarded nullable accessYes — criticalEvery DB lookup/find-by-id must have a null guard before property access
CC-NS2 non-null assertionYes — bannedNever emit ! assertions or !! in generated code
CC-NS3 nullable return typesYes — criticalRepository/service functions that can return null must declare it
CC-NS4 collection access guardYes — criticalNever generate items[0].x or .find().x without a prior guard
CC-NS5 validate external dataYes — criticalNever emit bare (await res.json()) as T; always validate first
CC-NS6 propagate nullYesService layer throws or returns typed null — not empty default objects
CC-AS1 await every promiseYes — criticalNever generate a floating async call without await or explicit handling
CC-AS2 consistent async styleYesNever mix await and .then() chains in the same generated function
CC-AS3 propagate async errorsYes — criticalNo bare catch { return null } in service or integration layers
CC-AS5 timeout on external callsYesEvery generated HTTP/DB call stub must include a timeout
CC-IV1 validate request bodyYes — criticalFirst statement of every generated POST/PUT/PATCH handler must be a schema parse
CC-IV2 validate path/query paramsYes — criticalNever pass req.params.* or req.query.* directly to a repo call
CC-IV3 sanitise stringsYesGenerated schemas must include .trim().min(1).max(N) on string fields
CC-IV4 validate env vars at startupYes — criticalGenerated config module must validate all env vars at process start
CC-IV5 reject unknown fieldsYesGenerated request schemas must use .strict() or extra='forbid'
CC-CS1 loop variable captureYes — criticalGo goroutines must copy loop var; JS must use let not var in loops
CC-CS2 React state updatesYessetState depending on previous value must use functional updater form
CC-CS5 idempotency keysYesGenerated payment routes and queue consumers must include idempotency/dedup check

Rules that do NOT apply to scaffold: CC-S2, CC-S3, CC-I1, CC-I2, CC-F1, CC-F2, CC-F3, CC-AS4, CC-CS3, CC-CS4.


Reviewer Reference Map

The reviewer reads SKILL.md first to determine which sub-files are relevant based on the diff content.

Reviewer checkSub-files to readFindings added
Check 1 — Pattern conformancenaming.md + hygiene.md + null-safety.md + async-safety.md + input-validation.md + concurrency-safety.md + interface.md (if new functions with many params)All check IDs below
Check 4 — Test coveragehygiene.md (CC-H2 only)cleancode-dead-code
Check 5 — Architecture fitnessstructure.md + frontend.md (if diff includes frontend files)cleancode-fn-length, cleancode-single-responsibility, cleancode-abstraction-levels, cleancode-component-size, cleancode-props-interface, cleancode-logic-extraction

Check IDs (check field in findings result contract):

cleancode-fn-length
cleancode-single-responsibility
cleancode-abstraction-levels
cleancode-naming
cleancode-magic-value
cleancode-param-count
cleancode-boolean-trap
cleancode-dry
cleancode-dead-code
cleancode-premature-abstraction
cleancode-component-size
cleancode-props-interface
cleancode-logic-extraction
cleancode-null-unguarded
cleancode-null-assertion
cleancode-null-return-type
cleancode-null-collection
cleancode-null-external
cleancode-null-swallowed
cleancode-async-unawaited
cleancode-async-mixed-style
cleancode-async-error-swallowed
cleancode-async-parallel-mutation
cleancode-async-no-timeout
cleancode-iv-body-unvalidated
cleancode-iv-params-unvalidated
cleancode-iv-string-unsanitised
cleancode-iv-env-unvalidated
cleancode-iv-unknown-fields
cleancode-cs-loop-capture
cleancode-cs-stale-closure
cleancode-cs-shared-mutable
cleancode-cs-nonatomic-reads
cleancode-cs-nonidempotent

Keep looking

Skills are one crate of 627,801. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.