From cosmo-agent-skills
Guidelines for implementing code changes: think first, keep diffs minimal and simple, surface assumptions, and verify with tests including edge cases. Use when writing new code, fixing bugs, or refactoring — before and during implementation.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cosmo-agent-skills:code-writingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Behavioral guidelines for **implementing** code well — complementary to
Behavioral guidelines for implementing code well — complementary to
code-reviewer (review after you write). Inspired by Karpathy's LLM coding
notes; stack-specific rules
belong in the repo's CLAUDE.md.
Tradeoff: These bias toward caution and small diffs over speed. For trivial, one-line fixes, use judgment — still run relevant tests.
Trace the call path and boundaries (I/O, JIT, config, public API) before changing code. Do not move heavy initialization, network, or disk access into hot inner loops without an explicit reason.
Do not assume. Do not hide confusion. Surface tradeoffs.
Before implementing:
Default: minimum code that solves the problem. Avoid speculative generality.
Ask: "Would a senior engineer call this overcomplicated?" If yes, simplify.
When simple is not enough: Some problems genuinely need more code — numerical stability, concurrency, performance, correctness under edge cases, or matching an existing architecture. Complexity is allowed when a simpler approach fails or would be wrong. Prefer the simplest thing that works, not the simplest thing that almost works.
If you add complexity:
Balance with verification: Simplicity is not an excuse to skip tests. A minimal repro test or edge-case check is often the simplest correct fix for a bug — that extra code is justified when it defines success. Likewise, a more elaborate implementation is justified when tests or requirements show the minimal one cannot.
Touch only what you must.
When editing existing code:
When your changes create orphans:
Test: Every changed line should trace to the user's request (or to a test that proves the fix).
Turn tasks into verifiable outcomes:
| Task | Success criteria |
|---|---|
| Add validation | Tests for invalid inputs pass; valid path unchanged |
| Fix a bug | Test reproduces bug, then passes after fix |
| Refactor | Full relevant suite green before and after |
| New feature | Acceptance cases + edge cases tested |
For multi-step work, state a short plan with checks:
1. [Step] → verify: [test or command]
2. [Step] → verify: [test or command]
Prefer criteria you can verify yourself (tests, scripts) over vague "make it work." If criteria are weak, propose stronger ones before coding.
After substantive edits:
pytest from repo root — see CLAUDE.md).Do not hand off "should work" without running tests you can run.
| Skill | When |
|---|---|
| code-testing | Test-first cycle, verify red/green, edge cases, full suite |
| code-reviewer | After implementation; before merge or next plan task |
Repo CLAUDE.md | Test commands, JIT rules, domain physics, env |
Write with code-writing; test with code-testing; review with code-reviewer.
npx claudepluginhub licongxu/cosmo-agent-skills --plugin cosmo-agent-skillsGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.