prepare-dataset

prepare-dataset is a command for coding agents from jjmartres/ai-coding-agents. It costs 61 tokens per session (1,364 once invoked), scanned A, original, MIT.

A command for examining a CSV, JSON, JSONL, TSV, or Parquet data file and generating a Python script that turns it into JSONL examples for fine-tuning with Unsloth. Fine-tuning means training a model further on task-specific examples.

In plain words
What is it for?
Inspecting columns, types, row counts, missing values, and samples; choosing source fields; estimating generated question-and-answer pairs; and preparing a fine-tuning dataset.
Why use it?
It helps decide which fields are useful, how much training data can be created, and what to do when the source file is too small or incomplete.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/jjmartres/ai-coding-agents/prepare-dataset
Clone the repo
git clone --depth 1 https://github.com/jjmartres/ai-coding-agents

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for prepare-dataset

README.md
[![agentmods](https://agentmods.dev/badge/commands/jjmartres/ai-coding-agents/prepare-dataset.svg)](https://agentmods.dev/commands/jjmartres/ai-coding-agents/prepare-dataset)
Your own site
<a href="https://agentmods.dev/commands/jjmartres/ai-coding-agents/prepare-dataset"><img src="https://agentmods.dev/badge/commands/jjmartres/ai-coding-agents/prepare-dataset.svg" alt="Measured on agentmods" height="20"></a>
Per session 61 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,364 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00061 $0.01364
Opus 5 $0.00030 $0.00682
Sonnet 5 $0.00012 $0.00273
Haiku 4.5 $0.00006 $0.00136

Measured 5d ago against content hash 02e981d87481, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

prepare-dataset scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

shared/.ai-agents/commands/prepare-dataset.md · 155 lines

How it starts

The opening of the file, as written. The whole thing — 155 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Arguments

  • $FILE : path to the source file (e.g. data/products.csv, data/clients.json)
  • $GOAL : one sentence describing what the model should be able to do after fine-tuning (e.g. "answer questions about our product catalogue in English")

Steps

1. Analyse the source file

Start by reading and analysing $FILE:

  • Detect the format (CSV, JSON, JSONL, TSV, Parquet) and the delimiter if CSV
  • Identify all available fields/columns and their types (string, number, bool...)
  • Count the total number of rows
  • Measure the missing value rate per field
  • Display 3 sample rows to understand the structure
  • Identify rich fields (few missing values, varied content) vs. sparse fields (>50% empty, constant values)

2. Propose a strategy

Based on $GOAL and the analysis, propose:

  • Which fields to use and why (exclude fields that are too empty or irrelevant)
  • How many Q&A pairs per source row can be generated (~5 to 30 depending on richness)
  • Estimated final dataset size (rows x average examples)
  • If the dataset is too small (<100 final examples): suggest an augmentation strategy (phrasing variants, synthetic data)
  • Recommended filter (e.g. "keep only rows where field X is filled")

Wait for validation before generating the script.

3. Generate scripts/dataset/<n>.py

Generate a Python script that inherits from BaseDatasetPreparer (see scripts/dataset/base.py), with the following structure:

Header and imports

"""
scripts/dataset/<n>.py
──────────────────────────
Short description of what this script does.
Source : $FILE
Goal   : $GOAL

Usage :
    uv run sg-<n> --input data/<n>.csv --stats
    uv run <n>-quality
"""

Lookup tables (if codes or abbreviations are present in the data) Generate Python dicts to translate them into human-readable text (e.g. country codes -> names).

Class <n>Preparer(BaseDatasetPreparer) with two methods:

generate_examples(self, row: dict) -> list[dict]

  • Takes one source row as input
  • Returns a list of dicts {"instruction": str, "input": str, "output": str}
  • Generates between 5 and 30 Q&A pairs per row depending on data richness
  • Covers each important fact under 2-3 different phrasings (e.g. "What is X of Y?" / "Give me X for Y." / "What is the X value of Y?")
  • Includes at least one "full record" question that aggregates all fields
  • Handles missing fields gracefully (if field: before using)
  • All questions and answers match the language implied by $GOAL

Read the full file on GitHub · 155 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 155 lines · 61 tokens per session scan A 02e981d87481

Subscribe to this mod's changes

prepare-dataset is a command published in the GitHub repository jjmartres/ai-coding-agents (44 stars, last pushed 2mo ago), licensed MIT. It adds 61 tokens to every session and 1,364 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.