> ## 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.

# Starter Code

> Learn about how to create starter code for a language

Starter code is the code that we provide to users when they start a challenge. It's the code that they'll be building on top of.

[Here's an example](https://github.com/codecrafters-io/build-your-own-redis/tree/main/compiled_starters/python).

## 1. Run `course-sdk add-language <language>`

<Steps>
  <Step title="Clone build-your-own-<challenge>">
    For instance, if you’re adding support for the Kafka challenge, clone the [build-your-own-kafka](https://github.com/codecrafters-io/build-your-own-kafka) repository.
  </Step>

  <Step title="Run course-sdk add-language <language>">
    a. Install [course-sdk](https://github.com/codecrafters-io/course-sdk) if it’s not already installed.

    b. In the cloned challenge repository, run the following command:

    ```bash theme={null}
    course-sdk add-language <language>
    ```

    <Info>
      Check available languages
      [here](https://github.com/codecrafters-io/language-templates/tree/main/languages).
    </Info>
  </Step>
</Steps>

## 2. Edit starter code

The starter code will be copied to `starter_templates/<language>`.

Suppose you're adding C support, open and edit `starter_templates/c/code/src/main.c`:

<Frame>
  <img className="w-full" src="https://mintcdn.com/codecrafters/qGKwe-_AIUAS3RUS/img/contributors/starter-code-skeleton.jpg?fit=max&auto=format&n=qGKwe-_AIUAS3RUS&q=85&s=e2072ca020f56b9f49cc5a5287f4cab9" width="2048" height="1536" data-path="img/contributors/starter-code-skeleton.jpg" />
</Frame>

Make necessary edits so the code can pass the first stage of the challenge.

## 3. Run `course-sdk test <language>`

We have comprehensive CI tests in place to ensure that the starter code and Dockerfile for each language are valid.

In the cloned challenge repository, run the following command:

```bash theme={null}
course-sdk test <language>
```

Ensure all tests pass before submitting a pull request (PR).

## First stage solution

To make it easier for users to get started, we automatically generate a solution to the first stage of the challenge. This is done by uncommenting lines in the starter code.

**Example**:

<Frame caption="Stage 1 solution, auto-generated from starter code">
  <img className="w-full" src="https://mintcdn.com/codecrafters/qGKwe-_AIUAS3RUS/img/contributors/first-stage-solution.png?fit=max&auto=format&n=qGKwe-_AIUAS3RUS&q=85&s=7d7626f9c6432b31f7c1f252f49a330d" width="2504" height="1492" data-path="img/contributors/first-stage-solution.png" />
</Frame>

The way this works is that [course-sdk](https://github.com/codecrafters-io/course-sdk) will look for markers like this in the starter code:

```python theme={null}
# Uncomment this to pass the first stage
```

These markers will be deleted and any code after them will be uncommented to generate the solution.

The full logic for this is [here](https://github.com/codecrafters-io/course-sdk/blob/4beb239db2293a5a5b109dac737c6a2d70d62d1a/lib/compilers/first-stage-solutions-compiler.ts).
