# Convert a GitHub repo to a Cookiecutter template

If you are using GitHub templates to standardize your service creation, it is possible to convert the templates for use within a [Cortex Workflow](https://docs.cortex.io/streamline/workflows).

This guide explains how to convert a GitHub repository template into a [Cookiecutter](https://www.cookiecutter.io/) template, enabling a more efficient process when you scaffold the repository from a Workflow.

In this guide, assume the repository has the following structure:

```json
Dockerfile
ReadMe
pipeline.yaml
/App
   |- App.py
```

## How to convert a GitHub template to a Cookiecutter template

1. Clone the existing GitHub repository locally.
2. Create a cookiecutter.json file, including the basic inputs needed from the user, other fields that will be used in the template, and the version (required). For example:

```json
{
	"project_name":"my project",
	"author":"author@example.com",
	"version": 0.1.0
}
```

3. Create a base folder with a name similar to:\
   `{{ cookiecutter.project_name }}`
4. Move the contents of the repo into to folder you created in Step 3. For example:

```json
/{{cookiecutter.project_name}}
    |- Dockerfile
    |- ReadMe
    |- pipeline.yaml
    |- App
         |- App.py
cookiecutter.json
```

5. In each of the files and folders, replace existing fields with the corresponding Cookiecutter fields.
   * For example, a Dockerfile may include the line `MAINTAINER author@example.com`. This can be changed to the following:

```json
MAINTAINER  {{cookiecutter.author}}
```

6. Optionally, add content to the README in the repository to document what the Cookiecutter template does.
   * When [registering a Scaffolder template](https://docs.cortex.io/streamline/workflows/scaffolder), you can choose whether to display the README in Cortex when running a Scaffolder block in a Workflow.

### Handling existing mustache templating in a repository file

You may have files that already contain mustache templating. In an instance where you do not want these interpreted as Cookiecutter fields, you can escape the curly braces, as described in [Cookiecutter's troubleshooting docs here](https://cookiecutter.readthedocs.io/en/stable/troubleshooting.html?utm_source=chatgpt.com).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cortex.io/streamline/workflows/scaffolder/convert-template.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
