AgentSkillsCN

skill-coding-standard

CORE: Haskell/SCSS/Nix的L1实现标准——如何写出正确的代码。

SKILL.md
--- frontmatter
name: skill-coding-standard
description: "CORE: L1 implementation standards for Haskell/SCSS/Nix. How to write correct code."
type: core
layer: L1

Coding Standard (L1: Implementation)

Core Question

Is this code correct by construction?

Quick Reference

AspectStandard
TypesExplicit signatures on all functions
TextUse Text not String (except Hakyll APIs)
ImportsExplicit: import Data.Maybe (fromMaybe)
ErrorsMaybe/Either, never error
External toolsSubprocess via readProcess
DependenciesNix only (flake.nix)

Thinking Prompt

Before implementing:

  1. Is this at a Hakyll API boundary? (They use String)
  2. Does similar code exist? (grep -r "pattern" src/)
  3. Can this function fail? → Use Maybe/Either

Trace UP ↑ (When to Escalate)

SymptomIndicates
Same error after 3 fixesWrong layer - design issue
"Where should this live?"Architecture question (L2)
Type gymnasticsDesign smell

Anti-Patterns

Don'tBetter
fromJustPattern match or fromMaybe
error "msg"Return Maybe/Either
Wildcard importsExplicit imports
Copy-paste codeExtract helper

Validation Commands

bash
nix build  # Must pass

# Check duplicates
grep -rh "^[a-z][a-zA-Z0-9_]* ::" src/ --include="*.hs" | \
  sed 's/ ::.*//' | sort | uniq -c | sort -rn | head -5