Establishes precedence, code quality, root-cause debugging, security checks, and continuity checkpoints. Use when writing, reviewing, or debugging code, running quality or security checks, or saving reasoning before finishing, handoff, or compaction. Covers Loaf's guidance precedence, reproducing a failure before fixing it, regression tests that fail without the fix, flaky tests, threat review for auth and data handling, secret scanning, and selective journal checkpoints. Not for git workflow (use git-workflow), architecture or project documentation (use architecture), or changelogs and releases (use release).
Resources
1Install
npx skillscat add levifig/loaf/dist-amp-skills-loaf-core Install via the SkillsCat registry.
Loaf Core
Guidance precedence, engineering and evidence standards, and ordinary continuity discipline for useful, recoverable work.
Contents
- Critical Rules
- Verification
- Quick Reference
- Topics
- Available Checks
- Debugging
- Security
- Naming Conventions
- Test Patterns
- Journal Commands
Critical Rules
Before the first journal write, select the form in Journal Commands and use it for every entry.
Precedence
When guidance conflicts, follow this order:
- The operator's instruction.
- The selected work contract.
- The project's documented direction, such as AGENTS.md and architecture docs.
- The project's existing conventions and toolchain.
- Loaf's defaults, including the conventions in loaded skills.
A selected contract may change documented direction; update that documentation in the same change. Prior decisions, existing code, and journal entries are evidence to weigh, not authority. When a simpler or better direction serves the outcome, say so and propose it instead of extending what exists by default.
Always
- Use type hints on all public functions
- Validate inputs at trust boundaries
- Deliver rideable increments: complete, useful operator journeys whose breadth is narrow without weakening integrity
- Before substantive edits, including ordinary fixes and regression tests, establish and verify a selected native issue. Load the loaf-reference skill's Flow Semantics for the canonical prerequisite and narrow exceptions, then use the project-management skill for provider operations. Honor an existing explicit implementation request without asking for selection again; an issue in Backlog alone is not selected work.
- Before a final response or handoff, load the project-management skill and apply its Capture Deferred Work rule to concrete deferred or out-of-scope findings; do not leave actionable future work only in prose or the journal.
- Record significant decisions and discoveries as they happen. Before completing substantial work, handing off, or compacting context, write a concise
wrap(scope)checkpoint only when useful reasoning is missing from existing records. Preserve abandoned approaches and why, unresolved uncertainty, and the next useful step when applicable. Routine interactions need no redundant checkpoint; omit empty fields and do not repeat raw events. See Continuity.
Never
- Use bare
except:clauses - Show stack traces or internal details to users; for secrets and personal data, follow the secrets rule
Verification
After Editing Files
Format Checking:
- For Python files: If
blackis available, runblack --check {files} - For TypeScript/JavaScript files: If
prettieris available, runprettier --check {files} - For Ruby files: If
standardrbis available, runstandardrb --format quiet {files}or ifrubocopis available, runrubocop --format quiet {files} - Auto-fix commands:
- Python:
black {files} - TypeScript/JavaScript:
prettier --write {files} - Ruby:
standardrb --fix {files}orrubocop -a {files}
- Python:
TDD Advisory:
- When editing implementation files (not test/spec files):
- Check if corresponding test file exists
- If no test found, consider Test-Driven Development:
- Write a failing test first
- Then implement the feature
- Run tests until green
- Expected test file patterns:
- Python:
test_{name}.pyor{name}_test.py - TypeScript/JavaScript:
{name}.test.{ext}or{name}.spec.{ext} - Ruby:
spec/{name}_spec.rbortest/{name}_test.rb - Go:
{name}_test.go
- Python:
Before Committing
- Run appropriate formatter on all changed files
- Run linter/type checker for the language
- Verify tests exist for new functionality
- Run test suite if tests were modified
- Add or update the changelog entry that the release skill's Changelog rules require
Workflow Notes
- Quick fixes with existing test coverage may skip TDD advisory
- Configuration and generated files don't need tests
- Editor format-on-save helps maintain compliance automatically
Quick Reference
| Context | Python | TypeScript |
|---|---|---|
| Files | snake_case.py |
PascalCase.tsx (components) |
| Functions | snake_case |
camelCase |
| Classes | PascalCase |
PascalCase |
| Constants | UPPER_SNAKE |
UPPER_SNAKE |
| Tests | test_<unit>_<scenario>_<result> |
describe/it blocks |
Topics
| Topic | Reference | Use When |
|---|---|---|
| Code Style | references/code-style.md | Writing Python/TypeScript code, naming variables |
| TDD | references/tdd.md | Writing tests first, red/green/refactor cycle |
| Verification | references/verification.md | Verifying work before claiming done |
| Code Review | references/code-review.md | Requesting or receiving code reviews |
| Review | references/review.md | Conducting structured code reviews |
| Permissions | references/permissions.md | Configuring tool allowlists, sandbox, agent permissions |
| Observability | references/observability.md | Instrumenting services, logging, metrics, tracing |
| Production Readiness | references/production-readiness.md | Validating services are ready for production |
| Rideable Increments | references/rideable-increments.md | Shaping, implementing, reviewing, or sequencing complete operator journeys |
| Continuity | references/continuity.md | Recording decisions, selectively checkpointing reasoning or an undecided Exploration, and recovering it in fresh context |
Available Checks
| Check | Command | Notes |
|---|---|---|
| Commit message | loaf check commit-msg <file> or loaf check commit-msg - |
File or stdin. Same conventional-commit engine as loaf check --hook validate-commit. Hook JSON is not accepted. |
| Micro-changelog | loaf check changelog <file.md> |
Document ## Changelog schema from the release skill's Changelog rules. validate-push / workflow-pre-pr do not replace this. |
| Python test naming | loaf check test-naming [dir] |
Real gate for file, function, and fixture names. The former script always exited 0. |
| Legacy ADR | loaf kb validate --legacy-adr <file> |
Already native. |
Python style
The former check-python-style.py helper walked the Python AST for type hints, docstrings, bare except:, print(), and logger context fields. A faithful Go port needs a Python parser; this checkpoint does not add that dependency and does not ship a regex stand-in. Use project linters, and enable the mapped rules in project ruff and pyright configuration — they are not implied by a default install:
| Former AST check | Mapped tooling |
|---|---|
| Public function missing return type hints | ruff ANN201 |
| Public function missing parameter type hints | ruff ANN001 or pyright reportMissingParameterType |
| Public function, method, or class missing docstring | ruff D103, D102, D101 |
Bare except: |
ruff E722 |
print() instead of structured logging |
ruff T201 |
| Logger call without keyword context fields | Skill convention only; no standard ruff/pyright rule |
Security checks are listed under Security.
Debugging
Diagnose from evidence, not by trying fixes.
- Reproduce first. Confirm a reliable trigger before investigating. If the failure cannot be reproduced, gather more signal (logs, inputs, state, environment) instead of changing code.
- Preserve evidence such as logs, state, and stack traces before changing anything.
- Hypothesize before changing code. List the plausible causes, test the most likely first, and keep each one's status (pending, ruled out, confirmed) written down, including the ruled-out ones.
- Change one variable per experiment, so a result has one explanation.
- Fix the root cause, not the symptom, and state the cause where the fix is recorded.
- A bug fix carries a regression test that fails with the fix reverted and passes with it. Confirm that failure when it is cheap; when you could not, say so.
- Flaky tests: run the test alone and in random order, control time, randomness, and shared state, and call it fixed only after repeated consecutive passes.
- Before reporting an investigation complete, load the project-management skill and apply its Capture Deferred Work rule to any unresolved cause, residual defect, or deferred correction.
Security
Loaf's security enforcement lives in these checks. This section names them; it does not change what they enforce.
| Check | When it runs | What it does |
|---|---|---|
check-secrets hook |
Before file edits and shell commands, on harnesses that run Loaf's pre-tool hooks; blocking, fails closed | Scans written content and shell commands for hardcoded secrets |
security-audit hook |
Before shell commands, on harnesses that run Loaf's pre-tool hooks; blocking, fails closed | Blocks dangerous shell patterns; runs available scanners only for thorough validation or reviewer and implementer agents |
loaf check secrets [dir] |
On demand | Walks a directory for assignment-style secrets, .env files, and key filenames. Different from the hook payload scan. |
loaf check compliance <file.md> |
On demand | Requires every - [ ] box to be checked. A file with no boxes passes. |
Where these hooks do not run, run loaf check secrets over the directories you changed before committing.
| Harness | Pre-tool security hooks |
|---|---|
| Claude Code, Cursor, OpenCode, Amp | Run |
| Codex | Not projected; run loaf check secrets before committing |
Secrets rule: never put secrets, credentials, tokens, or personal data in source, version control, logs, or error output; read them from the environment or a secret manager.
For a change that touches authentication, authorization, cryptography, or personal data, work out how its inputs, identities, and permissions could be abused before writing it, then review the change against those paths with least privilege and deny-by-default in mind.
Naming Conventions
| Context | Python | TypeScript |
|---|---|---|
| Files | snake_case.py |
PascalCase.tsx (components) |
| Functions | snake_case |
camelCase |
| Classes | PascalCase |
PascalCase |
| Constants | UPPER_SNAKE |
UPPER_SNAKE |
| Tests | test_<unit>_<scenario>_<result> |
describe/it blocks |
Artifact Names Never Cite Their Work Unit
Name an artifact for what it is, never for the work unit that produced it. The directory or Change that contains it already records that provenance, so repeating it in the filename inverts the reference and rots the moment the work closes: a work unit points at its artifacts, artifacts never point back.
| Instead of | Write |
|---|---|
u8-claude-smoke.mjs |
smoke-claude-code-startup.mjs |
report-spec-053-taxonomy-signoff.md |
taxonomy-signoff.md |
TASK-074-sidecar-audit-report.md |
sidecar-audit.md |
Provenance belongs in a front-matter field such as source:, where it can be read and updated, not in a name that has to be renamed to stay true.
Two look-alikes are correct and stay. A version is identity, not reference: claude-code-2.1.218-plugin-startup-smoke.json. A timestamp records when, not which work unit: 20260620-214448-skills-audit.md. And a numbered record living in the directory that owns it is that entity, so .agents/specs/SPEC-042-slug.md and docs/decisions/ADR-007-slug.md are its own name rather than a citation.
loaf check --hook artifact-names enforces this at commit time over tracked artifacts, grandfathering anything already final or archived.
Test Patterns
Scenario-based fixture naming:
*_perfect- Complete, valid data (happy path)*_degraded- Partial data, quality issues*_chaos- Edge cases, malformed data
Coverage target: 70% minimum across all components.
Journal Commands
Use the ordinary command loaf journal log "type(scope): description" with your harness's permissions. Apply only the labeled section for the harness you are running.
Codex
With Loaf's managed basic-command policy installed, use loaf journal log --execpolicy-safe "type(scope): description" for every entry, including checkpoints. Keep --execpolicy-safe immediately after journal log and invoke PATH loaf as a standalone command, without an absolute executable pin or shell/environment wrapper. The flag does not install the policy or grant permission by itself; without the policy, use the ordinary command and Codex's approval flow.