Goal
Generate realistic, comprehensive synthetic data for subject in a Jupyter notebook only after the applicable dataops synthetic-data operation preflight passes. Use example_data when the user supplies an existing data source, schema, or file to use as a strict reference for structure and patterns.
Inputs
subject: Required. User query describing the subject for synthetic data generation.example_data: Optional. Free-form input describing an existing data source, schema, or file to use as a reference for structure and patterns.
Required steps
Step 0: Validate synthetic-data operation preflight
- Activate the
dataopsskill by stable name and read its synthetic-data operation contract. - Require a
SYNTHETIC_DATA_OPERATION_V1preflight record before creating a project, installing packages, creating a notebook, accessing a source, or generating data. - Run the
dataopsvalidatecommand. Continue only when the gate passes with a current approved applicable classification decision carrying data-owner authority. - Treat protected-attribute generation and subgroup evaluation as inactive unless current qualified decision references explicitly mark them applicable. Protected-attribute generation requires privacy, Responsible AI or fairness, and domain-owner roles. Subgroup evaluation requires Responsible AI or fairness and domain-owner roles plus every activated subgroup reference.
- For
replace-local, require one existing regular local file under a caller-approved root, a matching expected SHA-256 source digest, and current approved applicable data-owner replacement authority. Reject directories, links, remote stores, network shares, databases, APIs, and multi-target operations. - If validation fails, stop before any write or source access. Report only stable categories, record identifiers, counts, and digests, plus the smallest qualified-owner action needed to resume. Do not reproduce source values in chat or records.
Step 1: Perform mandatory project setup
- After validated preflight, create the project folder and notebook using the file naming convention.
- Use
create_directoryto make the project folder. - Use
create_new_jupyter_notebookto create the notebook file. - Stop and confirm both are created before proceeding.
Step 2: Validate data source
Skip this step when the user does not mention an existing data source, schema, or file.
- If the user mentions an existing data source, schema, or file, first attempt to locate and access it.
- Write inspection code in a separate cell to load and examine the existing data.
- If the data source cannot be found, opened, or accessed, inform the user:
The specified data source '[name]' cannot be accessed. Please verify the file exists and is accessible. Cannot proceed with synthetic data generation.Then stop all processing. - If the source is found, use it as the strict reference for structure, schema, and patterns.
Step 3: Select data operation mode
- Default to
new-outputand create a versioned output without modifying an existing source. - If told to update or add to existing data, use
replace-localonly when Step 0 authorized it. Generate one candidate file beside the confirmed local target. Notebook code must never write the original source directly. - After generation, produce a separate result record linked to the exact preflight revision. Record observed source and output digests, actual field lineage, activated subgroup results, validation evidence, and the proposed commit state.
- Recheck the target digest and obtain separate runtime overwrite confirmation immediately before commit. Route the final replacement through the
dataopscommit-localcommand, which creates a recoverable predecessor, validates synchronized staging, and performs one replacement. - On stale source, predecessor failure, staged-validation failure, denied confirmation, or interruption before replacement, stop and retain
unchanged-originalevidence. Do not create a variant target or retry silently. - If told to create new synthetic data, follow the normal generation process.
- When working with an existing schema, adhere strictly to all fields, data types, and relationships.
Step 4: Protect PII
- Do not decide whether data or fields are sensitive. Use the qualified classification and protected-attribute applicability references from the validated preflight.
- Generate protected attributes only when the applicable qualified decision activates them. Use the approved generator reference and record field-level lineage without placing generated values in operation records or chat diagnostics.
- Use Faker or a similar generator only when permitted by the preflight and record the generator and seed references.
Step 5: Set up image processing
Skip this step when no image processing is mentioned.
- If the user mentions reading images or OCR, verify Tesseract is installed before proceeding. The goal is to extract text from images that can represent an ERD or data fields to inform synthetic data generation.
- Use a terminal tool to check
tesseract --version. Do not show this command in chat. - If Tesseract is not installed, inform the user:
Tesseract OCR is required for image processing. Please install it first using: brew install tesseract (macOS) or appropriate package manager for your system. - Proceed with image-related data generation only after confirming Tesseract availability.
Output requirements
Default export format
- For new synthetic datasets, export data as CSV unless the user requests another format, such as JSON, Parquet, or Excel.
- For authorized
replace-local, generate one candidate only. Do not write the original source from notebook code or create extra exports. Route the separately confirmed replacement throughdataopscommit-local.
Default data size
- If the user does not specify a size, keep synthetic datasets at or below 10,000 rows or objects.
- When generating files, balance comprehensiveness, performance, and usability.
Data comprehensiveness
Synthetic data should closely mimic real-world data in distributions, correlations, and patterns:
- Use realistic ranges and distributions for numerical values.
- Incorporate common categorical values and their relationships.
- Reflect temporal patterns, such as seasonality, when applicable.
- Represent geographic or demographic variations when applicable.
- Incorporate seed values for reproducibility. Generate a truly random seed programmatically, such as
random_seed = random.randint(1, 100000)orrandom_seed = int(datetime.now().timestamp()), rather than hardcoding values like42.
Distinguishability and subgroup evidence
- If a real dataset was provided and source access is authorized, measure the AUC of a model that tries to distinguish between real and synthetic data. Label this global distinguishability evidence, not subgroup fairness evidence.
- Run subgroup checks only for qualified activated subgroup references. Record each activated group as
passed,failed,insufficient, ornot-measured. Never collapse missing evidence into success. - Follow the detailed distinguishability and comprehensiveness protocol.
Visualization display requirements
- Render all visualization cells inline in the notebook output. Call
plt.show()in each visualization cell. - Saving charts to files is optional and must be in addition to inline display. If saving, call
plt.savefig(...)and still callplt.show(). Do not rely only on file writes. - Do not call
plt.close()beforeplt.show()in visualization cells because that suppresses inline rendering. Closing figures after showing is acceptable.
Project organization
Create a descriptive project structure
Organize all files for the synthetic data project in a dedicated folder based on subject to prevent workspace clutter.
File naming convention
- Parse
subjectand extract key concepts for naming. - Create the project folder with the format
{parsed_subject}/, such asweather_12_states_12_months/. - Create the notebook file at
{project_folder}/synth_{parsed_subject}.ipynb. - Create the CSV file at
{project_folder}/synthetic_{parsed_subject}_data.csv.
Examples:
weather for 12 states for 12 months- Folder:
weather_12_states_12_months/ - Notebook:
weather_12_states_12_months/synth_weather_12_states_12_months.ipynb - CSV:
weather_12_states_12_months/synthetic_weather_12_states_12_months_data.csv
- Folder:
sales data for retail stores- Folder:
sales_data_retail_stores/ - Notebook:
sales_data_retail_stores/synth_sales_data_retail_stores.ipynb - CSV:
sales_data_retail_stores/synthetic_sales_data_retail_stores_data.csv
- Folder:
Important file-management rules:
- For new synthetic datasets, export data only once in the designated export cell. Multiple exports create confusion and workspace clutter.
- For existing data source updates, update the original file only through
dataopscommit-local. Do not create additional CSV exports or backup files in wrong locations.
Notebook structure requirements
Create a well-structured notebook with these cells:
- Title cell in Markdown with a clear title using
subject. - Package installation cell in Python that installs required packages with
%pip install pandas numpy matplotlib seaborn scipy. - Library import cell in Python.
- Data structure explanation in Markdown that explains the data structure and approach.
- Candidate preparation cell in Python for authorized
replace-local, writing one candidate beside the confirmed target without modifying the target. - Data generation function in Python with detailed comments.
- Parameter configuration in Markdown that explains data-generation parameters.
- Data generation execution in Python.
- Data export in Python. For new datasets, export once. For
replace-local, write only the candidate path approved by the preflight. - Multiple visualization cells in Python using matplotlib and seaborn. Include map visualizations if data contains geographic information. These cells must display plots inline using
plt.show(). Saving withplt.savefig(...)is optional and must not replace inline display. - Summary statistics in Python for comprehensive data analysis.
- Validation and quality checks in Python to verify data comprehensiveness.
- Distinguishability measurement in Python. If an authorized real dataset is provided, measure AUC of a model distinguishing real from synthetic data. Do not present it as subgroup fairness evidence.
Use the notebook code template as the starter structure and adapt it to the subject domain and approved operation mode.
Analysis and planning
First, analyze the subject domain:
- Research what realistic data should look like for the subject.
- Identify key variables and data fields that are essential.
- Define relationships between variables, including correlations and dependencies.
- Consider temporal patterns, such as seasonality, trends, and cyclical behavior.
- Understand geographic or demographic variations when applicable.
Data structure requirements
Design a thoughtful data structure that includes appropriate data types, realistic ranges, distributions, correlations, and domain patterns.
For date and time handling:
- Convert any value sampled from
pd.date_rangeto Pythondatetime.dateordatetime.datetimeusingpd.Timestamp(day).date()orpd.Timestamp(day).to_pydatetime(). - Cast any integer value used in
timedeltato Pythonintusingint(value)before passing it totimedelta. - Never pass numpy types directly to Python standard library date or time functions.
Example:
day = np.random.choice(pd.date_range(start=start_date, end=end_date))
day = pd.Timestamp(day).date() # Ensures Python datetime.date
hour = int(np.random.choice(range(8, 19)))
minute = int(np.random.randint(0, 60))
start_time = datetime.combine(day, datetime.min.time()) + timedelta(hours=hour, minutes=minute)
Use the domain-specific requirements in data-domain-patterns.md when designing fields and distributions.
Implementation guide
Environment setup
- Use
configure_python_environmentto automatically set up the Python environment. - Use
configure_notebookto prepare the notebook environment. - Use
notebook_install_packagesto installpandas,numpy,matplotlib,seaborn, andscipy.
Project creation
- Validate the
dataopspreflight before any project creation. - Parse
subjectto extract key concepts for naming. - Create a descriptive project folder using
create_directory. - Create the notebook using
create_new_jupyter_notebookwith the queryGenerate synthetic data for {subject} with realistic patterns and comprehensive analysis.
Notebook development
- Use
edit_notebook_fileto create structured cells as outlined above. - When creating code cells, specify
language="python"in theedit_notebook_filetool call so the cell type is correct. - Use
run_notebook_cellimmediately after creating each cell. Do not ask the user to run code manually. - Do not provide code in Markdown format or chat messages. Create executable notebook cells through tools.
- Never provide code blocks for the user to copy and paste. Create and execute cells directly in the notebook.
- Do not display terminal commands in chat. Execute them directly using the terminal tool.
- Create and execute all code through notebook tools without displaying code content in chat.
- Complete notebook creation and code execution continuously without pausing or triggering continuation requests after notebook creation begins.
- Ensure all code executes without errors before proceeding. If any cell fails, fix the error and rerun before creating the next cell. If the error cannot be fixed after two attempts, inform the user of the issue and stop further processing.
- Export data only once in the designated export cell.
- Ensure every visualization cell ends with
plt.show()so figures render inline in the notebook output.
Validation
- Run all cells to ensure end-to-end functionality.
- Confirm realistic data patterns and distributions.
- Verify the project folder contains both the notebook and data file.
Required outputs
- Jupyter notebook with organized cells.
- Modular, parameterized data generation function with type hints.
- Realistic data that domain experts would find believable.
- File management that creates one export for new datasets, or creates one candidate for authorized
replace-localwhiledataopsowns confirmed replacement and predecessor recovery. - Multiple charts using matplotlib and seaborn, displayed inline with
plt.show(). Include map visualizations if data contains geographic information. - Comprehensive descriptive statistics.
- Quality checks to ensure data comprehensiveness and realism.
- Global AUC for distinguishing real from synthetic data when authorized, plus separate conditional subgroup evidence for qualified activated groups.
- Clear Markdown explanations for each notebook step.
Quality standards
- Realism: Data should look authentic to subject matter experts.
- Completeness: Cover all important aspects of the domain.
- Scalability: Functions should work with different dataset sizes.
- Flexibility: Allow customization through parameters.
- Statistical validity: Distributions and correlations should make sense.
- Usability: Data should be ready for analysis, modeling, or visualization.
Final deliverables
- Project folder with organized, descriptive structure.
- Complete Jupyter notebook with all required cells.
- Data management that creates one data file for new datasets, or creates one candidate for authorized
replace-localand routes any confirmed replacement throughdataopscommit-local. - Rich notebook documentation.
- Multiple visualizations showing data patterns and relationships.
- Data validation evidence showing realistic, high-quality synthetic data.
- Distinguishability and subgroup evidence, with global AUC when authorized and explicit results for every qualified activated subgroup without a fairness claim.
Project structure example:
weather_12_states_12_months/
├── synth_weather_12_states_12_months.ipynb
└── synthetic_weather_12_states_12_months_data.csv
Stop rules
- Stop before any write, package installation, source access, notebook creation, project creation, or data generation when the
SYNTHETIC_DATA_OPERATION_V1preflight is missing or fails validation. - Stop when an existing data source mentioned by the user cannot be found, opened, or accessed.
- Stop when an authorized
replace-localoperation loses source-digest freshness, predecessor creation, staged validation, runtime overwrite confirmation, or confinement. - Stop when Tesseract is required for image processing and is unavailable.
- Stop after two failed attempts to fix a notebook cell execution error.