Index of every page on this site: llms.txt
All skills
meza avatar

/clean-code

@982e21e
by mezameza/skills2 stars
Run it yourself

Use when designing, writing, refactoring, reviewing, or explaining code, tests, APIs, modules, or architecture. Provides a progressive catalog of clean-code qualities covering comprehension, domain modeling, state and failure behavior, boundaries, evolvability, operability, safety, and test design.

Use this Skill: https://skilld.dev/gh/meza/skills/clean-code

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencestest-placement-and-isolationunit-tests-avoid-physical-i-o.md

≈594 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Unit tests avoid physical I/O

Unit tests verify focused behavior without touching the real filesystem, network, database, clock, or other physical/environmental resources unless that resource is the behavior under test.

A good unit test gives precise evidence about a small piece of behavior while staying fast, deterministic, and isolated. Filesystem access should normally be abstracted behind an interface, adapter, fake, in-memory filesystem, or mock so the unit can be tested without physical I/O. Physical filesystem access, including OS temporary files or directories, is acceptable only when the unit's behavior genuinely depends on filesystem semantics that a mock would hide, such as permissions, path handling, locking, atomic writes, symlink behavior, or real encoding and newline behavior. Strong signs include one clear behavior per test, direct assertions about outputs or visible effects, explicit edge cases, simple setup, mocked or in-memory file access, injected clocks and randomness, and no dependency on prior test execution. Weak signs include casual use of tmpfiles for convenience, tests that read or write ambient paths, global state leaks, real network or database access, excessive mock choreography, assertions that duplicate implementation logic, and tests of private implementation detail. This symptom matters because unit tests should be cheap, deterministic, and safe to run constantly. Review should ask whether any physical I/O in the unit test is essential to the behavior being proven, or whether it should be mocked, faked, or moved to an integration test.

Examples

Bad

test "expired cache refreshes report" [misplaced broad test: filesystem, wall clock, live HTTP]:
  files = OSFileSystem(tempDirectory())
  clock = SystemClock()
  api = HttpReportApi("https://reports.example.test")
  files.write("report.cache", cached("old", expires = clock.now() - 1 second))
  report = ReportService(files, api, clock).current()
  assert report == "new"

Good

test "expired cache refreshes report" [unit]:
  files = InMemoryFileSystem()
  clock = FixedClock("2030-01-01T00:00:00Z")
  api = FakeReportApi(returning = "new")
  files.write("report.cache", cached("old", expires = clock.now() - 1 second))
  report = ReportService(files, api, clock).current()
  assert report == "new"
  assert api.calls == 1

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts28d3 checks · Risk SAFE
  • Gen Agent Trust Hub28d

    The skill 'clean-code' is a comprehensive educational catalog of software engineering principles and clean-code qualities. It provides structured guidance and pseudocode examples to help AI agents reason about code quality, security, and maintainability. No malicious code, hidden instructions, or security risks were identified during the analysis.

  • Socket28d

    No alerts

  • Snyk28d

    Risk: LOW · No issues

Signed by skilld at 982e21e. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 weeks ago.

Activeupdated 3 months ago

README badge

README badge for meza/skills/clean-code