cultivating-ml-agent
AGENTS.md5 starsChanged 34 days agoMITView on GitHub
This file guides Claude Code (or any AI coding agent) to autonomously execute ML competition workflows using the Cultivating ML Agent framework. This project provides a knowledge-driven MLOps framework for training ML agents from novice to competition-level performance. It combines: Upon installation, the agent should: Follow this exact sequence: Every experiment script (run_r{NN}_{name}.py) MUST follow this structure:
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository63 other files it gives its agents.
- adversarial-validation-kaggleSkill
- agent-nurture-frameworkSkill
- agent-session-memory-protocolSkill
- arxiv-paper-searchSkill
- autogluon-firstSkill
- autogluon-preset-strategySkill
- autogluon-timeseries-strategySkill
- catboost-first-tabularSkill
- claudeceptionSkill
- code-competition-artifact-pipelineSkill
- competition-orchestration-multimodelSkill
- context-engineeringSkill
- controlled-submission-experimentSkill
- cross-competition-feature-transferSkill
- cv-lb-gap-acknowledgmentSkill
- domain-knowledge-constraints-trapSkill
- ensemble-model-correlation-trapSkill
- feature-engineering-saturation-detectionSkill
- gpu-readiness-assessmentSkill
- gsd-loop-engineeringSkill
- kaggle-cognitive-cost-optimizationSkill
- kaggle-competition-best-practicesSkill
- kaggle-competition-type-strategySkill
- kaggle-data-format-firstSkill
- kaggle-discussion-searchSkill
- kaggle-experiment-sopSkill
- kaggle-oof-lb-validation-protocolSkill
- kaggle-optimal-blendingSkill
- kaggle-submission-format-by-metricSkill
- kaggle-top-performer-replicationSkill
- knowledge-crystallization-feedback-loopSkill
- ladder-drift-and-meta-aware-regressionSkill
- learned-value-beats-heuristic-augmentationSkill
- llm-competition-pipelineSkill
- mcts-pipeline-searchSkill
- mem0-dynamic-graph-memorySkill
- memory-hierarchy-managementSkill
- ml-sweet-spot-principleSkill
- model-ensemble-negative-weight-effectSkill
- multi-agent-rolesSkill
- multi-level-aggregation-overfittingSkill
- okf-visualize-knowledgeSkill
- onnx-minimal-network-designSkill
- per-category-modeling-backfireSkill
- progressive-verification-debuggingSkill
- ptcg-2ply-bounded-searchSkill
- ptcg-bc-large-model-submissionSkill
- retail-eda-frameworkSkill
- rmsle-zero-threshold-asymmetrySkill
- runtime-reflexionSkill
- sc-tir-mathematical-reasoningSkill
- self-evolving-skillsSkill
- skill-governance-and-automationSkill
- spatiotemporal-graph-feature-engineeringSkill
- store-sales-darts-chronos-blendSkill
- tabular-polynomial-features-breakthroughSkill
- three-layer-wisdom-extractionSkill
- time-series-walk-forward-validationSkill
- trueskill-simulation-competition-strategySkill
- ts-day-specific-forecastingSkill
- The first 60 shown.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
18 rules. About 0 are common, 10 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Read this file for operational instructions
- Very specific: line 20
Use framework/ modules for pipeline structure
- Distinctive: line 21
Follow the five-stage learning loop for continuous improvement
- Distinctive: line 27
Follow this exact sequence:
- Very specific: line 41
Every experiment script (run_r{NN}_{name}.py) MUST follow this structure:
- Very specific: line 116
Every run_r{NN} must have:
- Distinctive: line 119
If it doesn't work, document WHY and move on
- Distinctive: line 123
Always compute CV score before submitting
- Distinctive: line 124
If CV doesn't improve, don't submit (wastes daily quota)
- Very specific: line 129
After any non-trivial finding, run /claudeception to extract a skill AND persist to the Obsidian Memory Vault:
- Very specific: line 166
After experiment, record in ~/obsidian/ml-agent-memory/experiments/experiments.md:
- Distinctive: line 242
When encountering a problem, check skills in this order:
- Distinctive: line 269
If gap > 5%, investigate overfitting
- Distinctive: line 270
Update README with results
- Distinctive: line 317
After completing an experiment or finding a breakthrough:
- Very specific: line 320
Principles: If finding transfers across domains, add to principles/16-principles.md
- Very specific: line 321
Competition record: Update competitions/{name}.md with latest version and findings
- Very specific: line 322
Skills: If anti-pattern discovered, add/update skills/{skill-name}.md
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md — Autonomous ML Learning Agent Instructions
This file guides Claude Code (or any AI coding agent) to autonomously execute ML competition workflows using the Cultivating ML Agent framework.
Overview
This project provides a knowledge-driven MLOps framework for training ML agents from novice to competition-level performance. It combines:
- Framework code (
framework/) — Reusable Python modules for config, logging, validation, MLflow tracking - Skills library (
skills/examples/) — 19 crystallized patterns from real competitions - Main guide (
docs/cultivating-ml-agent-expert.md) — Methodology (1088 lines) - Templates (
templates/) — Skill creation templates
When Agent Is Activated
Upon installation, the agent should:
- Read this file for operational instructions
- Browse
skills/examples/for available domain knowledge - Use
framework/modules for pipeline structure - Follow the five-stage learning loop for continuous improvement
Agent Workflow
Starting a New Competition
Follow this exact sequence:
1. Read competition overview (metric, data format, submission format)
2. Copy framework/config_template.yaml → config.yaml, fill in competition details
3. Copy framework/script_template.py → scripts/run_r01_baseline.py
4. Run EDA: data shapes, class balance, missing values, feature types
5. Build baseline (single model, no feature engineering)
6. Submit to LB — this is your floor score
7. Iteratively improve: R02, R03, ... with clear namingPer-Experiment Workflow (5-Stage Pipeline)
Every experiment script (run_r{NN}_{name}.py) MUST follow this structure:
Stage 0: Configuration
- load_config("config.yaml", overrides={...})
- get_logger("R{NN}_{name}")
- argparse: --smoke, --no-mlflow, --override
Stage 1: Data Loading
- Load train/test/sample_submission
- Log shapes: log.data_shape("train", df)
- Validate: validate_pipeline(train, test, cfg)
Stage 2: Feature Engineering
- Create features
- Validate: validate_features(df, FEATURE_COLS)
- Log feature count and names
Stage 3: Model Training
- Train with CV (5-fold default)
- Log CV score: log.metric("CV", score)
- Save model artifact
- Save OOF predictions for stacking
Stage 4: Prediction + Submission
- Generate predictions
- get_submission_filename() for naming
- validate_and_save() for format checking
- evaluation_gate() to block regressions
- Submit to Kaggle LBFramework Module Map
| Module | Import | Purpose |
src/config.py | from config import CompetitionConfig, load_config | Type-safe YAML config with CLI overrides |
src/utils/logging_utils.py | from utils.logging_utils import get_logger | Timestamped experiment logging |
src/utils/metrics.py | from utils.metrics import get_metric | Competition metric functions |
src/utils/submission.py | from utils.submission import validate_and_save, get_submission_filename | Submission format validation |
src/utils/paths.py | from utils.paths import get_competition_dirs | Standard directory resolution |
src/pipeline/validate.py | from pipeline.validate import validate_pipeline, validate_features, evaluation_gate | Data quality + regression gates |
src/pipeline/mlflow_utils.py | from pipeline.mlflow_utils import start_experiment | MLflow experiment tracking |
Integration Pattern (Per-Project)
your-competition/
├── config.yaml # Competition-specific config
├── scripts/
│ ├── run_r01_baseline.py # Each experiment is self-contained
│ ├── run_r02_feature_eng.py
│ └── ...
├── src/ # Local modules (optional)
├── outputs/
│ ├── submissions/ # Kaggle submission files
│ ├── models/ # Saved model artifacts
│ └── oof/ # Out-of-fold predictions
├── data/ # Competition data (gitignored)
└── README.md # Experiment logAutonomous Learning Rules
Rule 1: Always Start Simple
Baseline (R01) → Single model, zero feature engineering
Feature Engineering (R02-R04) → Add ONE technique per experiment
Multi-Model (R05-R07) → Add model diversity
Ensemble (R08+) → Combine best modelsRule 2: One Hypothesis Per Experiment
Every run_r{NN} must have:
- A clear hypothesis: "Adding pairwise TE will improve CV by X"
- A single variable change from previous experiment
- If it doesn't work, document WHY and move on
Rule 3: CV Before LB
- Always compute CV score before submitting
- If CV doesn't improve, don't submit (wastes daily quota)
- Monitor CV-LB gap: if gap grows, you're overfitting
Rule 4: Extract + Persist Knowledge
After any non-trivial finding, run /claudeception to extract a skill AND persist to the Obsidian Memory Vault:
# After experiment completes, immediately persist:
# 1. Read the vault to know current state:
with open("~/obsidian/ml-agent-memory/dashboard.md") as f:
print(f.read())
# 2. Update competition record:
# → Append experiment result to ~/obsidian/ml-agent-memory/competitions/{name}.md
# 3. Update principles if cross-domain insight found:
# → Edit ~/obsidian/ml-agent-memory/principles/16-principles.md
# 4. Update skills if anti-pattern discovered:
# → Edit ~/obsidian/ml-agent-memory/skills/{skill-name}.mdAnti-patterns to record immediately (these save hours of wasted effort):
- "净化后 CV 没改善" → adversarial-validation.md
- "多模型 ensemble 相关性 >0.97" → ensemble_method.md
- "lag feature 全 NaN 导致低预测" → time_series.md
Rule 5: Consult Memory Before Acting
At these decision points, read the vault FIRST before writing any code:
| Trigger | File to Read | What to Look For |
| Starting a new competition | dashboard.md | Cross-competition patterns, highest ROI techniques |
| CV-LB gap > 0.01 | skills/adversarial-validation.md | AUC≈0.50 → stop purification, try GroupKFold |
| Feature engineering | dashboard.md | External data fusion ROI ~7x over self-training |
| Ensemble plateau | principles/16-principles.md | Quality over quantity: 4-6 sources > 23 sources |
| Time series lag features | skills/time_series.md | preds.mean()/train.mean() diagnostic first |
Rule 6: One Change Per Experiment — Document the Outcome
After experiment, record in ~/obsidian/ml-agent-memory/experiments/experiments.md:
### v{NN}_{name}
- **CV/LB**: 0.xxxx / 0.xxxx
- **做法**: [ONE sentence, what changed]
- **诊断**: [why it worked or didn't]
- **关键洞察**: `short_slug_name`
- **标签**: [comma-separated]Format follows experiment_log.jsonl conventions so both machine-readable (JSONL) and human-readable (MD).
Competition-Specific Guidance
Tabular Classification/Regression
Key skills to activate:
tabular-feature-engineering-patterns— 7 FE patternspairwise-target-encoding-strategy— Interaction encodingsigmoid-smoothing-target-encoding— High-cardinality encodingkaggle-optimal-blending— 80/20 blending ruleensemble-source-quality-over-quantity— Ensemble source selection
Typical progression:
- Baseline (LightGBM, default params)
- Target encoding for categoricals
- Pairwise interaction features
- Multi-model ensemble (XGB + LGB + CB)
- Pseudo-labeling (if test labels are predictable)
- Stacking + threshold optimization
- External data integration (if available)
Time Series Forecasting
Key skills:
ts-forecasting-stale-lag-methodology— Complete lag feature guidets-lag-out-of-sample-trap— Lag leakage preventionts-lag-nan-cascade-bug— NaN handlingdense-grid-cv-lb-divergence— CV strategy for dense gridsunified-vs-day-specific-forecasting— Model architecture choice
Typical progression:
- Baseline (global model, basic lags)
- Time features (day-of-week, month, holidays)
- Lag features with out-of-sample prevention
- Per-store or per-category models (carefully!)
- Ensemble of unified + day-specific models
- Post-processing (clipping, rounding)
Recommendation Systems
Key skills:
kaggle-recommendation-recall-bottleneck— Recall > ranking insightkaggle-submission-id-reset-index-bug— Submission format traps
Typical progression:
- Co-occurrence / popular baseline
- Repurchase-based recall
- Item-to-item collaborative filtering
- GBDT ranking on recall candidates
- Layered prediction (high-confidence first, fill empty slots)
Framework Gotchas
These issues were discovered during real competition usage:
log.metric()only accepts floats — Uselog.info()for stringsget_data_path()may resolve to wrong directory — Usecfg.project_root / "data_raw"as fallbackevaluation_gate()requirescv_std— Pass0.0for single-fold validation- Config
config.pyname collision — Load local config before adding sharedsrc/tosys.path log_feature_importance()needs sklearn API — Rawlgb.train()Booster won't work; useLGBMClassifier- MLflow SQLite backend — Add
mlflow.dbto.gitignore
Skill Activation Priority
When encountering a problem, check skills in this order:
- Problem-specific — If the error/situation matches a skill's trigger, use it immediately
- Domain-specific — Activate domain skills (time series, tabular, etc.) at the start of a new competition
- Process skills — Use
claudeceptionafter breakthroughs,ml-pipeline-unit-testingbefore long runs
Experiment Naming Convention
run_r{NN}_{descriptive_name}.pyNN: Zero-padded 2-digit version (R01, R02, ..., R15)name: kebab-case technique description (e.g.,target_encoding,gbdt_framework)- Submission:
submission_r{NN}_{name}.csv
Quality Gates
Before any submission:
validate_pipeline()— No target leakage, shape checksvalidate_features()— No NaN/Inf in featuresvalidate_and_save()— Correct submission formatevaluation_gate()— CV score meets threshold
After any submission:
- Log LB score to MLflow:
log_lb_score(run_id, lb_score) - Compare CV vs LB gap
- If gap > 5%, investigate overfitting
- Update README with results
Obsidian Memory Vault Pattern
A filesystem-based knowledge base that persists across agent sessions. Any agent can read it to acquire accumulated experience from previous sessions.
Structure
~/obsidian/ml-agent-memory/ # home-relative, works on all Macs
# OR for iCloud sync (same vault, different absolute path):
# ~/Library/Mobile Documents/iCloud~md~obsidian/Documents/06_ML_Agent_Memory/
# Agents: use whichever path resolves on the running system.
├── competitions/ # Per-competition structured records
│ ├── s6e5.md # F1 Pit Stop — best LB 0.9526
│ └── s6e4.md # Irrigation — best LB 0.98150
├── experiments/ # Experiment timeline with results
│ └── experiments.md # 28 experiments, cross-competition patterns
├── principles/ # Layer 3 universal principles (cross-domain)
│ └── 16-principles.md # e.g. "Work Smart > Hard Work", "Local Optimum Trap"
├── skills/ # Core skill decision frameworks
│ └── adversarial-validation.md # Decision tree + AUC interpretation
└── memory/ # (optional, agent-only dir, gitignored)
├── experiment_log.jsonl
└── principles_index.jsonAgent Query Pattern
At any decision point, an agent can read relevant files:
# When starting a new competition:
with open("~/obsidian/ml-agent-memory/dashboard.md") as f:
insights = f.read()
# When diagnosing CV-LB gap:
with open("~/obsidian/ml-agent-memory/competitions/s6e5.md") as f:
competition_record = f.read()
# When deciding strategy:
with open("~/obsidian/ml-agent-memory/principles/16-principles.md") as f:
principles = f.read()When to Update Memory
After completing an experiment or finding a breakthrough:
- Experiments: Append to
experiments/experiments.mdwith CV/LB, key changes, key insight - Principles: If finding transfers across domains, add to
principles/16-principles.md - Competition record: Update
competitions/{name}.mdwith latest version and findings - Skills: If anti-pattern discovered, add/update
skills/{skill-name}.md
Quick Reference: Decision → File Mapping
| Decision Point | File | Key Content |
| Adversarial validation | skills/adversarial-validation.md | AUC 0.50 = stop purification |
| CV strategy | principles/16-principles.md P16 | GroupKFold when AUC≈0.50 |
| Feature engineering | dashboard.md | External data fusion highest ROI |
| Ensemble failure | skills/ensemble_method.md | Model correlation trap |
| Time series lag | skills/time_series.md | preds.mean()/train.mean() diagnostic |
Cross-Competition Patterns (from experiments.md)
| Technique | Effective For | Effect | Condition |
| Pairwise target encoding | s6e4, s6e5 | +0.001~+0.002 | categorical × numerical |
| External data fusion | s6e4, s6e5 | +0.001~+0.007 | Same target definition |
| Pseudo-labeling | s6e4 | +0.001 single round, -0.001 iterative | Threshold ≥0.90 |
| Polynomial features | House Prices | +0.016 (small dataset) | Rows < 10K |
| Adversarial purification | s6e5 | No benefit if AUC≈0.50 | Check first before filtering |
| Fork public kernels (code comps) | NeuroGolf, AI Agent Sec | +0.6% to +60% | When top kernels score near LB |
| BUDGET-FILLING attack (sim code comp) | AI Agent Security | 39 → 62 LB | Fill 97% of 9000s budget per model |
| Monkey-patch numpy 2.0 | Biohub | Made v16/v17 work | _center, _blas_supports_fpe shims |
Resources
- Main guide:
docs/cultivating-ml-agent-expert.md(1088 lines) - Framework config spec:
docs/framework/config-spec.md - Framework pipeline:
docs/framework/mlops-pipeline.md - Experiment workflow:
docs/framework/experiment-workflow.md - Project template:
docs/framework/project-template.md - Skill templates:
templates/bug-fix-skill.md,templates/knowledge-skill.md - Memory vault:
~/obsidian/ml-agent-memory/(see Obsidian Memory Vault Pattern above)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

