AGENT SKILL

harden

Ship one learning's structural_mitigation_candidate as a real test, then mark the learning's mitigation_type structural. Picks a learning in .living/learnings.md that is still ambient-awareness but names a concrete check, writes the test in the repository's own test setup, proves it fails when the learning's problem is present and passes on the current code, and updates only that entry after the user confirms. Use when the user asks to harden, enforce, or turn a learning, gotcha, or lesson into a test or structural mitigation. Do not use for recording a new learning, promoting learnings to conventions, adding checks inside analysis code, or changing Mycelium itself.

License 许可
MIT
最近更新
2026-11-08
Stars
★ 72
Forks
2

01 前言 Front Matter

name
harden
description
Ship one learning's structural_mitigation_candidate as a real test, then mark the learning's mitigation_type structural. Picks a learning in .living/learnings.md that is still ambient-awareness but names a concrete check, writes the test in the repository's own test setup, proves it fails when the learning's problem is present and passes on the current code, and updates only that entry after the user confirms. Use when the user asks to harden, enforce, or turn a learning, gotcha, or lesson into a test or structural mitigation. Do not use for recording a new learning, promoting learnings to conventions, adding checks inside analysis code, or changing Mycelium itself.

02 资源文件 1

03 SKILL.md 正文

<!-- Adapted from the harden skill in mycelium-extra (https://github.com/mdmanurung/mycelium-extra), Copyright (c) 2026 Mikhael Manurung, MIT License. See issue #91. -->

Mycelium — Harden

Resolve .living/ and test paths relative to the user's working repository.

Turn a learning the project keeps having to remember into a test that remembers it. A learning counts as structural only once its check has shipped (skills/core/templates/learning-entry.md); until then it stays ambient-awareness, the weakest kind. This skill ships the check. Harden one learning per run.

1. Find a candidate

  • Requires .living/learnings.md. Without it, say so and stop.
  • Search it for structural_mitigation_candidate, then read each matching entry. An entry starts at the ### [YYYY-MM-DD] heading above the match; older projects may use a legacy ## [YYYY-MM-DD] heading.
  • Keep entries whose mitigation_type is ambient-awareness and whose candidate names a concrete check: a function, file, column, or assertion. Skip the template placeholder and vague candidates ("be careful with X"). Leave convention entries and entries with no mitigation_type alone: a convention entry is already enforced, so harden does not take it, and an untyped entry needs its type derived first. An entry marked structural whose check never shipped re-derives to ambient-awareness, which makes it a candidate here. The type follows the rule in skills/core/templates/learning-entry.md; harden only ships a check, after which that rule makes the entry structural.
  • A candidate that places its check in analysis code ("In analysis/.../x.py, assert ...") still qualifies when the check reads a file a test can read too: show it with "(check moves to a test)". If it checks a value only the running script holds, skip it and say why: it needs a code change and a re-run through $mycelium:analyze.
  • Show at most five, newest first: date, title, and the candidate in one line. The user picks one. If none qualifies, say so and stop.

2. Place the test

  • Follow the repository's test setup: pytest.ini, [tool.pytest] in pyproject.toml, tests/testthat/, or existing test_*.py files and how they are run (check README, MYCELIUM.md, AGENTS.md, CLAUDE.md).
  • With no setup, create tests/test_<slug>.py (stdlib assert, runnable with python3) or tests/testthat/test-<slug>.R.
  • Never edit analysis code, and never place the test under analysis/, a notebook directory, or any path listed in ANALYSIS_MANIFEST.md. A check inside analysis code changes what ran, so it belongs to a new analysis run, not to this skill. For a candidate placed in analysis code, write the same assertion in the test, reading the file the analysis reads or writes, and leave the script as it is.
  • Name the test after the learning and cite it in a one-line comment: # Guards learning "<title>" (.living/learnings.md, <date>).

3. Prove it guards something

A test guards something only if it fails when the learning's problem is present and passes now. How to make the problem present depends on what the test checks:

  • A data check (a column, a sample count, a file format) asserts a property of a file. Its red run feeds the same assertion a small fixture, built in the test or a temporary file, that recreates the bad data. It must fail there.
  • A code check (a function's behavior) passes on the problematic input once the fix is in. Its red run is against the unmitigated implementation: the commit before the fix, checked out in a temporary git worktree (it holds only tracked files, so copy the new test into it), or the fix monkeypatched out inside a throwaway run. It must fail there, on its targeted assertion: a missing test, import error, or collection failure is not a red run. Then remove the worktree with git worktree remove --force <path> (--force because the copied test leaves it dirty), which also clears its Git metadata; deleting the directory alone does not. Never edit the repository's code to stage the red run, and never keep a test that fails on the input it is meant to handle.

Then the green run: the test must pass on the current code or data. Show both runs.

If it cannot be made to fail in its red run, it guards nothing: stop, and leave the entry ambient-awareness. If it fails on the current code, the problem is live: report it, and do not mark the learning structural.

For a data learning (a column, a sample count, a file format), the test may read the repository's data file. If that file is large or git-ignored, say the test only runs where the data exists.

4. Record, after the user confirms

Show the test path, both runs, and the exact edit, then ask. After the user confirms, edit only that entry:

  • **mitigation_type**: structural
  • **structural_mitigation_candidate**: <unchanged text> Shipped: <test path> (YYYY-MM-DD).

Append the Shipped: note to the end of the existing candidate text, even when that text wraps over several lines. Change no other field or entry, and do not commit. If Mycelium's Stop hook asks for .living/ updates afterwards, follow it. End with one line: the learning, the test path, and how to run it.

04 同仓库更多 Skills

arjunrajlaboratory
arjunrajlaboratory/mycelium

transfer

Cross-pollinate learnings across Science subprojects by scanning recent .living/learnings.md entries and identifying actionable knowledge transfers. Use when user says "transfer knowledge", "cross-pollinate", "sync learnings", or "knowledge transfer".

★ 72
arjunrajlaboratory
arjunrajlaboratory/mycelium

review

Review or audit analytical code and scientific changes in statistics, ML, bioinformatics, or data pipelines. Use for PRs, commits, diffs, sanity checks, correctness questions, pre-merge review, tripwire testing, or conversational grill mode. Consult the bundled statistical, leakage, bioinformatics, documentation, LLM-failure, and code-quality checklists; synthesize prioritized findings. Do not use for writing new analysis, reports, brainstorming, project initialization, or pure software review with no analytical component.

★ 72
arjunrajlaboratory
arjunrajlaboratory/mycelium

report

Create a shareable report — a PDF, or a self-contained HTML report with a companion slide deck — a manuscript section, or a structured writeup from completed Mycelium analyses. Load the project's report templates, provenance, section guidance, and QC checklist. Use when the user wants a document artifact for collaborators or publication. Do not use for conversational explanation, standalone figures, performing analysis, ingestion, setup, or brainstorming.

行政与办公人员文档处理
★ 72
arjunrajlaboratory
arjunrajlaboratory/mycelium

lifecycle-audit

Run a black-box Mycelium lifecycle smoke test through a real Claude Code or Codex CLI task. Use after plugin installation, hook, SessionStart, PostToolUse, Stop, activity tracking, handoff, or data-lineage changes; when automatic hooks appear not to fire; or before merging cross-host lifecycle work. Verify installed-build identity, natural dispatch, state transitions, positive and negative probes, and scientific-tree isolation. Do not use as a substitute for unit tests or for ordinary scientific analysis.

★ 72
arjunrajlaboratory
arjunrajlaboratory/mycelium

ingest

Add or import files and datasets into a Mycelium project with metadata, provenance, validation, and DATA_MANIFEST updates. Use for collaborator or facility outputs and formats such as CSV, FASTQ, XLSX, TIFF, JSON, FCS, TSV, or images. Do not use for analyzing existing data, listing datasets, deleting data, downloading URLs, or editing code.

电子表格
★ 72
arjunrajlaboratory
arjunrajlaboratory/mycelium

ideas

Brainstorm research ideas using installed persona and ideation conventions. Use for fresh perspectives, creative angles, new analysis directions, expert viewpoints, "what are we missing?", or other open-ended exploration. Do not use for a defined analysis, code fix, project setup, or data ingestion task.

★ 72