AI-Assisted Research Coding

Research Code Review for Silent Bugs and Leakage

Reviews training or analysis code for bugs that do not cause a crash but corrupt the results: leakage, wrong splitting, wrong metrics and uncontrolled randomness.

Advanced File analysis prompt AI agent prompt Not rated yet

Purpose of the prompt

The most dangerous research code bugs are the ones that run without error messages. The prompt focuses on the correctness of the scientific results before style, and asks for evidence from the code for every comment.

When to use it?

Before running the final experiments, and before publishing the code with the paper.

Full prompt text

Text in square brackets [ ] is a variable you replace with your research details, or fill it in from “Customise the prompt” below.

You are an expert code reviewer for research software and machine learning.

Review the following code (or the repository files if you are an agent working inside it):
<code>
[Code]
</code>

Experiment context: [Experiment context]

Review in the following order, and for each comment give: the file and line, the problem, why it affects the results, and the suggested fix:
1. Data leakage: preprocessing, normalisation or feature selection before splitting, overlap between sets, using the test set for tuning or early stopping.
2. Correctness of the metrics: averaging (macro/micro), thresholds, computing metrics per batch instead of over the whole set.
3. Randomness and reproducibility: seeds, non-deterministic operations, data ordering.
4. Silent bugs: array shapes, model.eval() or no_grad, class order, different normalisation between training and testing.
5. Then performance and style, briefly.

Classify each comment: critical (changes the results), important, improvement.

Constraints:
- Do not mention a problem whose location in the code you cannot point to.
- If you are an agent and you modified the code, run the tests and show their output, and do not claim a success you have not verified.

Write the answer in [Answer language].

Customise the prompt

Fill in only what suits you. The line of an empty optional field is removed from the final text, and empty required fields stay in brackets for you to complete later.

Preview of the customised prompt

You are an expert code reviewer for research software and machine learning.

Review the following code (or the repository files if you are an agent working inside it):
<code>
[Code]
</code>

Experiment context: [Experiment context]

Review in the following order, and for each comment give: the file and line, the problem, why it affects the results, and the suggested fix:
1. Data leakage: preprocessing, normalisation or feature selection before splitting, overlap between sets, using the test set for tuning or early stopping.
2. Correctness of the metrics: averaging (macro/micro), thresholds, computing metrics per batch instead of over the whole set.
3. Randomness and reproducibility: seeds, non-deterministic operations, data ordering.
4. Silent bugs: array shapes, model.eval() or no_grad, class order, different normalisation between training and testing.
5. Then performance and style, briefly.

Classify each comment: critical (changes the results), important, improvement.

Constraints:
- Do not mention a problem whose location in the code you cannot point to.
- If you are an agent and you modified the code, run the tests and show their output, and do not claim a success you have not verified.

Write the answer in [Answer language].

Variables you can customise

[Code]
Required
[Experiment context]
Optional
[Answer language]
Optional, choose from: Arabic, English, Arabic with English terms in parentheses, default value: Arabic with English terms in parentheses

Usage example

Example input

A PyTorch training script for image classification with normalisation, splitting and evaluation in one file.

Expected output

A list of comments classified by severity, with the location of each problem in the code and its fix.

How to use it

  • Start with the files responsible for data loading, splitting and evaluation.

Tips for better results

  • After the fix, ask for a unit test that stops each critical bug from coming back.

Limitations and warnings

  • Automated review does not guarantee the code is bug-free.

Suggested tools for using this prompt

Tools from the directory of research and academic publishing tools that are actually linked to this prompt's task, with the reason each tool is suggested.

Google Colab

Tool: Optional Free with usage limits

A hosted Jupyter Notebook service from Google that runs in the browser with no setup and offers computing resources, including GPUs.

Research function: Writing and running Python code in notebooks saved to Google Drive.

Why it is suggested: To run the code after the fix and check the results.

In research workflows

Ratings

Not rated yet
Rate this prompt

One rating per visitor per prompt; submitting again updates your earlier rating. Comments appear after review.

Similar prompts