Coding
Get code that fits your project, find the real cause of a bug, and analyze data files in Chat or Codex.
Code generation
Get functions from exact signatures and examples, code that follows your conventions, tests alongside it, and builds in reviewable pieces.
4 techniques →-
How Do You Get ChatGPT to Write Tests With Its Code? Ask for the tests in the same request as the code, and name the edge cases yourself. Level 2: Context
- 1List the behaviors
- 2Write the tests
- 3See them fail
- 4Code until they pass
-
How Do You Get ChatGPT to Write the Function You Actually Want? Give ChatGPT the exact signature and a few real input and output examples, and ask only for the body. Level 2: Context
- Normal case"Hello, World!" gives "hello-world"
- Edge case"Crème brûlée" gives "creme-brulee"
- Invalid caseAn empty string raises ValueError
-
Why Shouldn't You Ask ChatGPT for a Whole App at Once? You can't review it, so you can't trust it. Level 2: ContextHard to reviewEasy to review
- Whole app
- One feature
- One screen
- One tested function
-
How Do You Get ChatGPT to Write Code That Fits Your Project? State your language, versions and conventions before asking for code, and save them so you don't have to repeat them. Level 2: Context
- 1Global style~/.codex/AGENTS.md or custom instructions
- 2This repoAGENTS.md or project instructions
- 3This taskThe prompt
Debugging
Paste the exact error, cut the bug down to the smallest failing code, ask for causes before fixes, and reset after two failed attempts.
4 techniques →-
How Do You Stop ChatGPT From Guessing at Bug Fixes? Tell it not to fix anything yet. Level 2: Context
- 1The symptom
- 2Likely causes
- 3A check that tells them apart
- 4Then the fix
-
How Do You Give ChatGPT a Bug It Can Actually Fix? Cut the problem down to the smallest code that still fails, then give ChatGPT that code, the exact input, the output you expected and the output you got. Level 2: Context
- The whole fileIt guesses which part matters
- The failing functionLess to suspect
- The smallest code that failsWith input, expected and actual output
- One failing testRun it to prove the fix
-
What Should You Paste Into ChatGPT to Fix an Error? Paste the exact error text, the full stack trace, the command you ran, and the code at the failing line. Level 2: ContextDo
- The exact error and full trace
- The command you ran
- The code at the failing line
- Take out any secrets first
Don't- "It doesn't work"
- Your guess at the cause
- A screenshot with no explanation
-
What Do You Do When ChatGPT Keeps Giving the Same Wrong Fix? Stop after two failed attempts. Level 2: Context
- 1A fix fails
- 2Another variation fails
- 3Stop and write a handoff
- 4New chat, with what failed
Stuck again? Hand off again
Data analysis
Upload a CSV, explain your columns, check the Python and row counts behind each answer, and turn a cleanup into a reusable script.
4 techniques →-
How Do You Turn a ChatGPT Data Cleanup Into a Reusable Script? When a cleanup looks right, ask ChatGPT to put every step into one script that takes a file path, leaves the original alone and prints a short report on what it changed. Level 3: Workflows
- 1Clean it in chat
- 2Ask for one script
- 3Test it on last month's file
Each month, run the script instead of the chat -
Why Should You Explain Your Columns to ChatGPT First? A column name doesn't tell ChatGPT what it means. Level 2: Context
- amtNet revenue in EUR
- stA value of 3 means a refund
- dtInvoice date, not payment date
- Blank amtNot yet billed, never zero
-
How Do You Check ChatGPT's Data Analysis Is Right? Ask to see the Python it ran, the row count after each step and a small table behind every chart. Level 2: ContextThe chart
- The Python it ranfilters and joins
- Row countsafter each step
- A small tablebehind the chart
- One trusted numberto match against
-
How Do You Analyze a CSV File in ChatGPT? Upload the file with the paperclip, ask ChatGPT to describe what it sees without drawing conclusions, correct anything it got wrong, and then ask one question per message. Level 2: Context
- 1Upload the file
- 2Ask what's in it
- 3Check it read correctly
- 4Ask one question
Next question, in its own message
How well do you code and analyze data with ChatGPT?
Six scenarios on writing code, handling data and fixing bugs. Answers show after each pick, and you won't need to create an account.
Chat or Codex?
This is the choice that matters most for coding now. In a chat, ChatGPT can't see your repository, so it only knows what you paste and can't run your project. Codex can read your files and run commands inside a sandbox. OpenAI's plans give Free and Go Codex in the desktop app, subject to rollout, with the CLI and IDE extension starting at Plus. As a rule of thumb, use Chat for a single function or an explanation, and Codex once a task involves more than a couple of files or needs tests run.
Where the lessons fit
Code generation covers getting code that fits your project. Debugging covers what to do once something fails. Data analysis is a little different: ChatGPT itself writes and runs Python on files you upload, so you can work with real numbers without any setup. All three share one idea, which is to give ChatGPT something it can be checked against, such as a test, a reproduction or a total you already trust. Neither a tidy answer nor a confident tone is evidence that the code works.
Can ChatGPT write code?
Yes. In Chat, it writes code from what you paste, and you run it yourself. Codex, OpenAI's coding agent, can read your repository, edit files and run commands in a sandbox. The CLI and IDE extension start at Plus, at $20 a month as checked on 6 November 2026.
Can ChatGPT run code?
Its data analysis feature writes and runs Python on files you upload, but a chat can't run your own project. For that, use Codex, which can run your tests and commands in a sandbox that, by default, limits writes to your workspace and keeps network access off.
What's the best ChatGPT model for coding?
OpenAI's notes suggest Sol at Medium effort for everyday and complex coding, and Luna at High for focused, repeatable tasks. GPT-6 Astra is for the hardest end-to-end work, and it uses your allowance much faster. Availability depends on your plan.
Is Codex included with ChatGPT Plus?
Yes. OpenAI lists Codex on web, CLI, IDE and iOS for Plus, with usage limits. Free and Go have GPT-6 Luna in the desktop app, subject to rollout. You can also use Codex with an API key at API rates.