> ## Documentation Index
> Fetch the complete documentation index at: https://docs.codecrafters.io/llms.txt
> Use this file to discover all available pages before exploring further.

# How do challenges work?

> In CodeCrafters challenges, you'll write code to pass each stage and we'll verify your code submissions. Read more below to understand how exactly this works.

## How do challenges work

### 1. Setting up your Git repository

First off, we'll create a git repository for you. Like [this one](https://github.com/codecrafters-io/redis-starter-python). You'll use this repository to submit code to CodeCrafters to run tests.

You can choose what language to use at this point. You can freely switch between languages whenever you want.

<Frame>
  <img className="w-full" src="https://mintcdn.com/codecrafters/rBHxsHriiZT92xcM/img/setup-choose-language.png?fit=max&auto=format&n=rBHxsHriiZT92xcM&q=85&s=24849d588ba8624a7b51dca60e37ccaa" width="1194" height="804" data-path="img/setup-choose-language.png" />
</Frame>

Once you've selected a language, we'll create the git repository for you and provide instructions to push a test commit.

<Frame>
  <img className="w-full" src="https://mintcdn.com/codecrafters/rBHxsHriiZT92xcM/img/setup-test-commit.png?fit=max&auto=format&n=rBHxsHriiZT92xcM&q=85&s=b1f8acd8697433ece776268b4b8573c6" width="1192" height="894" data-path="img/setup-test-commit.png" />
</Frame>

#### How to run `git` commands?

<Tip>
  You need to run `git` commands on your local machine.

  <Steps>
    <Step title="Open Terminal on your system">
      If you're on Windows, you can use [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/windows-powershell/starting-windows-powershell#from-the-start-menu).
    </Step>

    <Step title="Set up Git">
      Make sure Git is [installed](https://git-scm.com/download) and [set up properly](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup).
    </Step>

    <Step title="Run git commands">
      Copy and paste the commands into your terminal, and press enter.

      <img className="w-full" src="https://mintcdn.com/codecrafters/rBHxsHriiZT92xcM/img/run-git-commands.jpg?fit=max&auto=format&n=rBHxsHriiZT92xcM&q=85&s=5b096e80d472d3cdfa3c6d82a9087f43" width="1680" height="806" data-path="img/run-git-commands.jpg" />
    </Step>
  </Steps>
</Tip>

Once we receive the test commit and have verified that your repository is setup correctly, you'll automatically proceed to the first stage.

### 2. First Stage Instructions

You'll now see instructions for the first stage.

<Frame>
  <img className="w-full" src="https://mintcdn.com/codecrafters/qGKwe-_AIUAS3RUS/img/bind-to-port.png?fit=max&auto=format&n=qGKwe-_AIUAS3RUS&q=85&s=e3a40cbba2e9e29586609b7c85a0199d" width="1296" height="800" data-path="img/bind-to-port.png" />
</Frame>

CodeCrafters follows a TDD-like approach. For each stage we'll run tests on your code. The tests will initially fail, and then you'll submit code to make those tests pass. In the terminal where you ran git push, you'll see test results available:

<Frame>
  <img className="w-full" src="https://mintcdn.com/codecrafters/rBHxsHriiZT92xcM/img/results-terminal.png?fit=max&auto=format&n=rBHxsHriiZT92xcM&q=85&s=184252936958aad72df78acb4ad74574" width="1830" height="2246" data-path="img/results-terminal.png" />
</Frame>

(Yes, git push output can contain colors!)

### 3. Passing the first stage

The README will contain [instructions on how to pass the first stage](https://github.com/codecrafters-io/redis-starter-python#passing-the-first-stage). We always include this along with your starter repository, so that it's easy to get started.

<Frame>
  <img className="w-full" src="https://mintcdn.com/codecrafters/qGKwe-_AIUAS3RUS/img/passing-first-stage.png?fit=max&auto=format&n=qGKwe-_AIUAS3RUS&q=85&s=9a3393a6cd55635e8b8d0aef7c4b3d33" width="1870" height="966" data-path="img/passing-first-stage.png" />
</Frame>

If you visit `app/main.py` as suggested above, you'll see some commented out code:

<Frame>
  <img className="w-full" src="https://mintcdn.com/codecrafters/qGKwe-_AIUAS3RUS/img/commented-out-code.png?fit=max&auto=format&n=qGKwe-_AIUAS3RUS&q=85&s=89510d0f3e5264d0e34e74ad92eead8c" width="1622" height="1168" data-path="img/commented-out-code.png" />
</Frame>

To pass the first stage, all you've got to do is uncomment the code above and then run a git push.

<Frame>
  <img className="w-full" src="https://mintcdn.com/codecrafters/qGKwe-_AIUAS3RUS/img/git-push.png?fit=max&auto=format&n=qGKwe-_AIUAS3RUS&q=85&s=dd221d2aa4ac9fa3f84edb87da37e8e3" width="1622" height="1168" data-path="img/git-push.png" />
</Frame>

When you run git push, you'll see the first stage pass.

<Frame>
  <img className="w-full" src="https://mintcdn.com/codecrafters/qGKwe-_AIUAS3RUS/img/first-stage-pass.png?fit=max&auto=format&n=qGKwe-_AIUAS3RUS&q=85&s=20035631391bfa178f3912d8ce816d76" width="1888" height="1634" data-path="img/first-stage-pass.png" />
</Frame>

### 4. Next stage

When you head back to the web UI, you'll now see instructions for the second stage:

<Frame>
  <img className="w-full" src="https://mintcdn.com/codecrafters/rBHxsHriiZT92xcM/img/respond-to-ping.png?fit=max&auto=format&n=rBHxsHriiZT92xcM&q=85&s=b557845ec37146d50dfba3cac51341d4" width="1292" height="848" data-path="img/respond-to-ping.png" />
</Frame>

A lot of care goes into crafting these stage instructions. They're tailored to the language you're using, and we ensure that you receive the right hints at the right time. All challenges are vetted by hundreds of early access users before being released to the public.
