{"id":16779537,"url":"https://github.com/di-sukharev/ai-tdd","last_synced_at":"2025-08-01T08:33:57.843Z","repository":{"id":147734105,"uuid":"618829175","full_name":"di-sukharev/AI-TDD","owner":"di-sukharev","description":"CLI for TDD — you write the test, GPT writes the code to pass it ✅","archived":false,"fork":false,"pushed_at":"2023-11-30T13:34:11.000Z","size":189,"stargazers_count":269,"open_issues_count":2,"forks_count":19,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-02T12:44:00.614Z","etag":null,"topics":["ai","artificial-intelligence","chatgpt","gpt","openai","productivity","tdd","test-driven-development"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/di-sukharev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-25T13:29:06.000Z","updated_at":"2025-03-13T03:00:54.000Z","dependencies_parsed_at":"2023-11-30T14:45:16.338Z","dependency_job_id":null,"html_url":"https://github.com/di-sukharev/AI-TDD","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/di-sukharev%2FAI-TDD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/di-sukharev%2FAI-TDD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/di-sukharev%2FAI-TDD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/di-sukharev%2FAI-TDD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/di-sukharev","download_url":"https://codeload.github.com/di-sukharev/AI-TDD/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085906,"owners_count":21045237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","artificial-intelligence","chatgpt","gpt","openai","productivity","tdd","test-driven-development"],"created_at":"2024-10-13T07:30:21.932Z","updated_at":"2025-04-09T18:23:00.698Z","avatar_url":"https://github.com/di-sukharev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cdiv\u003e\n    \u003cimg src=\".github/logo-sexy.svg\" alt=\"aitdd logo\"/\u003e\n    \u003ch1 align=\"center\"\u003eAI + TDD\u003c/h1\u003e\n    \u003ch4 align=\"center\"\u003eFollow the bird \u003ca href=\"https://twitter.com/_sukharev_\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/_sukharev_?style=flat\u0026label=_sukharev_\u0026logo=twitter\u0026color=0bf\u0026logoColor=fff\" align=\"center\"\u003e\u003c/a\u003e\n    \u003c/h4\u003e\n  \u003c/div\u003e\n\t\u003ch2\u003eGPT powered CLI for TDD\u003c/h2\u003e\n\t\u003ch2\u003eYou write the test — GPT writes the code until it passes the test ✅\u003c/h2\u003e\n\t\u003cp\u003ePrompting GPT with a test suite makes it write code impressively accurate\u003c/p\u003e\n\u003c/div\u003e\n\n---\n\n## Setup\n\nAITDD runs on [Bun](https://bun.sh/), make sure you first install the latest Bun version.\n\n1. Install AITDD globally as a CLI:\n\n   ```sh\n   curl -sSL https://raw.githubusercontent.com/di-sukharev/AI-TDD/master/install.sh | bash\n   ```\n\n2. Get your API key from [OpenAI](https://platform.openai.com/account/api-keys). Make sure you add payment details, so API works.\n\n3. Set the key to AITDD config:\n\n   ```sh\n   aitdd config set OPENAI_API_KEY \u003cyour_api_key\u003e\n   ```\n\n   Your api key is stored locally in `~/.aitdd/config` config file and is not stored anywhere in any other way.\n\n4. Set the command to run the tests:\n\n   ```sh\n   aitdd config set RUN_TESTS \"npm run test\"\n   ```\n\nYour api key is stored locally in `~/.aitdd/config` config file and is not stored anywhere in any other way.\n\n## Example\n\n\u003c!-- TODO: add CRUD example --\u003e\n\nHere is a frontend test suite written in [Jest](https://jestjs.io/) + [Testing Library](https://testing-library.com/). Yes, AITDD easily passes even frontend tests:\n\n```typescript\nimport React from \"react\";\nimport { rest } from \"msw\";\nimport { setupServer } from \"msw/node\";\nimport { render, fireEvent, waitFor, screen } from \"@testing-library/react\";\nimport \"@testing-library/jest-dom\";\nimport Fetch from \"../fetch\";\n\nconst server = setupServer(\n  rest.get(\"/greeting\", (req, res, ctx) =\u003e {\n    return res(ctx.json({ greeting: \"hello there\" }));\n  })\n);\n\nbeforeAll(() =\u003e server.listen());\nafterEach(() =\u003e server.resetHandlers());\nafterAll(() =\u003e server.close());\n\ntest(\"loads and displays greeting\", async () =\u003e {\n  render(\u003cFetch url=\"/greeting\" /\u003e);\n\n  fireEvent.click(screen.getByText(\"Load Greeting\"));\n\n  await waitFor(() =\u003e screen.getByRole(\"heading\"));\n\n  expect(screen.getByRole(\"heading\")).toHaveTextContent(\"hello there\");\n  expect(screen.getByRole(\"button\")).toBeDisabled();\n});\n\ntest(\"handles server error\", async () =\u003e {\n  server.use(\n    rest.get(\"/greeting\", (req, res, ctx) =\u003e {\n      return res(ctx.status(500));\n    })\n  );\n\n  render(\u003cFetch url=\"/greeting\" /\u003e);\n\n  fireEvent.click(screen.getByText(\"Load Greeting\"));\n\n  await waitFor(() =\u003e screen.getByRole(\"alert\"));\n\n  expect(screen.getByRole(\"alert\")).toHaveTextContent(\"Oops, failed to fetch!\");\n  expect(screen.getByRole(\"button\")).not.toBeDisabled();\n});\n```\n\nReady? Here is the code generated by AITDD (GPT-4) to pass the test:\n\n```jsx\nimport React, { useState } from \"react\";\n\nfunction Fetch({ url }) {\n  const [data, setData] = useState(null);\n  const [error, setError] = useState(null);\n  const [loading, setLoading] = useState(false);\n\n  async function fetchData() {\n    setLoading(true);\n    try {\n      const response = await fetch(url);\n      if (!response.ok) throw new Error(\"Failed to fetch\");\n      const data = await response.json();\n      setData(data.greeting);\n    } catch (error) {\n      setError(error.message);\n    } finally {\n      setLoading(false);\n    }\n  }\n\n  return (\n    \u003cdiv\u003e\n      {data \u0026\u0026 \u003ch1 role=\"heading\"\u003e{data}\u003c/h1\u003e}\n      {error \u0026\u0026 \u003cdiv role=\"alert\"\u003e{error}\u003c/div\u003e}\n      \u003cbutton onClick={fetchData} disabled={loading}\u003e\n        Load Greeting\n      \u003c/button\u003e\n    \u003c/div\u003e\n  );\n}\n\nexport default Fetch;\n```\n\n## Usage\n\nYou can call aitdd like this:\n\n```sh\naitdd run\n```\n\n## Payments\n\nYou pay for your own requests to OpenAI API. AITDD uses latest GPT model by default, check it's [pricing](https://openai.com/pricing). Maximum response tokens are set to 2000, you can adjust it via `ait config set maxTokens=\u003cnumber\u003e`.\n\nI couldn't manage ChatGPT model to solve the problem. I tried to few shot it with a response example, it doesn't understand what I want. If you want to try manage it via ChatGPT — test it and open a PR 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdi-sukharev%2Fai-tdd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdi-sukharev%2Fai-tdd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdi-sukharev%2Fai-tdd/lists"}