Commands
train.py
Turns documents you already have (team standards, style guides, .cursorrules) into scoped rules. Deterministic: it never calls a model.
Synopsis
python3 train.py --name myapp --from ~/docs/team-standards
python3 train.py --name myapp --from ./style.md --scope "glob:**/*.py"
python3 train.py --name myapp --from ~/docs/team-standards --dry-run # preview only
python3 train.py --name myapp --from ~/docs/team-standards --pending # review before they apply
Options
| Option | Meaning |
|---|---|
--name NAME required | The project (as registered by memorize.py or automatically). |
--from SRC required | A folder (searched recursively) or a single file. |
--scope SCOPE | Force one scope for everything: global, section:<name> or glob:<pattern,…>. Without it, the scope is worked out from each document. |
--pending | Store the rules as pending instead of active. |
--dry-run | Print the rules that would be created and store nothing. |
What it reads
In a folder it takes every .md, .mdx, .mdc and .txt file, plus .cursorrules and .windsurfrules, skipping .git and node_modules. Files that Lore itself generated (review.py sync) are recognised and skipped.
How a document becomes rules
- Bullets are rules. Every bullet (
-,*,+or1.) becomes one rule, with its continuation lines joined. Code blocks are skipped. - Prose is the fallback. A document with no bullets contributes its paragraphs instead (tables, block quotes and HTML are ignored).
- Cleaned up. Markdown links keep their text, bold markers are removed, whitespace is squashed. Text shorter than 12 or longer than 500 characters is dropped, and so are repeats within the file.
- Refused, not repaired. Text with hidden characters or HTML comment markers is counted as "refused" and reported.
Where a rule applies
- If the file has front matter with
applyTo:orglobs:, every rule in it gets aglobscope from it (**and**/*mean "everywhere" and are ignored). - Otherwise, the nearest heading that names exactly one section of the project wins: under "## API layer", with a section
src/api, the rule becomessection:src/api. - Otherwise,
global.
--scope overrides all of this.
Example
# Standards
## API layer
- Use the repository layer for database access
- Return errors as problem+json
## General
- Keep functions small and focused
$ python3 train.py --name myapp --from docs/standards.md --dry-run
[section:src/api] Use the repository layer for database access (standards.md)
[section:src/api] Return errors as problem+json (standards.md)
[global] Keep functions small and focused (standards.md)
$ python3 train.py --name myapp --from docs/standards.md
Read 1 file(s): 3 rule(s) added, 0 duplicate(s), 0 promoted
Review with: review.py --name myapp list
Notes
- Active by default. Documents you point it at are your own standards, so the rules apply at once. Use
--pendingto review first. - Safe to repeat. Near-identical rules in the same scope are not duplicated; a pending rule you retrain as active is promoted. Rules that reverse the meaning of an existing one are added and reported ("may contradict an existing one").
- Train on standards, not on everything. Status reports, checklists and changelogs also contain bullets. Short, concrete bullets work best ("Use the repository layer for DB access").
- After training, ask your agent to tag the new rules, so each is sent only when it matters. See tagging.