name: find-new-patterns
description: Identify recurring patterns in tasks and wiki files that could become conventions
argument-hint: "[tasks|wiki|]"
Scan lab/tasks/ and/or wiki/ files for recurring structural, formatting, or writing patterns that appear consistently across files but are not yet documented as conventions.
Steps
Parse
$ARGUMENTSto determine scope:- No argument → scan both
lab/tasks/andwiki/ tasks→ scan onlylab/tasks/wiki→ scan onlywiki/- A specific file path under
lab/tasks/orwiki/→ use that file's directory as the scope - If the argument is unrecognisable, ask the user.
- No argument → scan both
List all
.mdfiles in the scope directories (recursively forlab/tasks/).Read all convention files that apply to the scope:
- Always read
instructors/context/conventions/common.md - If scope includes
lab/tasks/: readinstructors/context/conventions/tasks.md - If scope includes
wiki/: readinstructors/context/conventions/wiki.md
- Always read
Read every
.mdfile in the scope. For each file, note recurring elements:- Structural patterns — how sections, headings, or sub-sections are organised
- Formatting patterns — how a particular element (command, note, image, link) is presented
- Writing patterns — a fixed phrase, sentence starter, or wording template used consistently
- Content patterns — a piece of information that is always included in a particular position (e.g., a "You should see…" line after a command)
Group identical or near-identical patterns across files. A pattern qualifies as a candidate if:
- It appears in 2 or more files (or 2 or more places in the same file if the scope is a single file), and
- It is not already covered by any rule in the convention files read in step 3.
For each candidate pattern record:
- Name — a short, descriptive label (e.g., "Post-step state check phrase", "Inline mini-ToC for methods")
- Occurrences — file paths and approximate line numbers where the pattern appears
- Example — one concrete excerpt showing the pattern as it appears in the files
- Gap — which convention file and section is closest to this pattern, and what rule is missing
- Proposal — one or two sentences describing what the convention rule would say if formalised
Rules
- Do not flag patterns that are already described (even partially) in the convention files. Only flag genuine gaps.
- Do not flag patterns that appear only once across all scanned files — a single occurrence is not a pattern.
- Do not invent patterns. Only report what is actually present in the files.
- Be specific: quote a short excerpt (1–5 lines) to illustrate each candidate.
- Distinguish between patterns that are consistent (all occurrences look the same → strong candidate) and near-consistent (most occurrences look similar with minor variation → weaker candidate, note the variation).
Output format
Write the report to tmp/find-new-patterns/report.md. Create intermediate directories if they do not exist.
Structure:
- Header — scope scanned, date, convention files consulted, total files read.
- Candidate patterns — one subsection per candidate, in descending order of occurrence count. Each subsection contains:
- Occurrence count and file list
- Example excerpt (fenced code block)
- Gap: nearest existing convention and what it does not cover
- Proposal: draft rule text
- Weak candidates (near-consistent patterns) — same format, clearly labelled as requiring author judgement.
- Summary — total strong candidates, total weak candidates, and a suggested priority order for formalising them.
After writing the file, print its path in the conversation so the user can find it.