This document explains how to create a new Python project from this template repository.
There are two separate phases:
- Prepare this repository as a GitHub Template repository.
- Create a new project repository from the template.
Do not confuse these steps.
Marking this repository as a template does not create a new project. Creating a new project happens only after using the Use this template button or the GitHub CLI equivalent.
This phase is done once for this repository.
If this repository is still local, initialize it and push it to GitHub:
git init
git add .
git commit -m "Initial Python AI-friendly template"
git branch -M main
gh repo create sagivba/python-ai-friendly-template --private --source=. --remote=origin --pushIf the repository already exists on GitHub and the latest files are committed locally, push the changes:
git status
git add .
git commit -m "Update Python project template"
git pushIn GitHub:
-
Open the template repository:
sagivba/python-ai-friendly-template -
Go to:
Settings -
In the
Generalsettings page, find:Template repository -
Enable the checkbox.
After this step, GitHub will show a button named:
Use this template
This means the repository is now ready to be used as a source for new repositories.
This phase is done every time you want to start a new project.
-
Open the template repository:
sagivba/python-ai-friendly-template -
Click:
Use this template -
Choose:
Create a new repository -
Enter the new repository name.
The repository name should match the intended project name, for example:
chemistry-mock-site -
Choose visibility:
Privateor:
Public -
Create the repository.
-
Clone the new repository locally:
git clone git@github.com:sagivba/chemistry-mock-site.git cd chemistry-mock-site -
Initialize the project from the template:
scripts/init_from_template.sh chemistry-mock-site
Or, if you want to explicitly control the Python package name:
scripts/init_from_template.sh "Chemistry Mock Site" --package chemistry_web
Run this from the parent folder where you keep your projects, not from inside another project.
cd ~/projects
gh repo create sagivba/chemistry-mock-site --template sagivba/python-ai-friendly-template --private --clone
cd chemistry-mock-site
scripts/init_from_template.sh chemistry-mock-siteWith an explicit Python package name:
scripts/init_from_template.sh "Chemistry Mock Site" --package chemistry_webWhen you use:
git clone git@github.com:sagivba/chemistry-mock-site.gitGit creates a new local directory:
chemistry-mock-site/
So the normal workflow is:
cd ~/projects
git clone git@github.com:sagivba/chemistry-mock-site.git
cd chemistry-mock-siteDo not run the template initialization script from src/.
Run it from the project root:
chemistry-mock-site/
├── AGENTS.md
├── README.md
├── scripts/
├── src/
└── tests/
Correct:
cd chemistry-mock-site
scripts/init_from_template.sh chemistry-mock-siteIncorrect:
cd chemistry-mock-site/src
../scripts/init_from_template.sh chemistry-mock-siteUse this only when you already created a local directory with the intended project name.
The current directory should be the project root. It should not be src/.
Example:
mkdir chemistry-mock-site
cd chemistry-mock-siteThen import the template files:
git clone --depth 1 git@github.com:sagivba/python-ai-friendly-template.git .template-tmp
cp -a .template-tmp/. .
rm -rf .template-tmp
rm -rf .git
git initInitialize the project:
scripts/init_from_template.sh chemistry-mock-siteThen continue with setup:
cp .env.example .env
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
scripts/test.sh full local
scripts/lint.shCreate and push the new GitHub repository:
git add .
git commit -m "Initialize project from template"
git branch -M main
gh repo create sagivba/chemistry-mock-site --private --source=. --remote=origin --pushThe initialization script updates the generated project after it has been created from the template.
It updates:
- project name
- Python package directory under
src/ - imports and package references
README.mdpyproject.toml.env.example- Docker-related project naming references where possible
It also creates:
.template-initialized
This marker prevents accidental repeated initialization.
A second run will fail unless you intentionally use:
scripts/init_from_template.sh chemistry-mock-site --forceUse --force only when you deliberately want to re-run initialization.
After running the initialization script and validating the project, commit the initialized state:
git status
git add .
git commit -m "Initialize project from template"If the repository was not pushed yet:
git branch -M main
gh repo create sagivba/chemistry-mock-site --private --source=. --remote=origin --pushBefore starting real development, verify:
- The repository name matches the intended project name.
- The local directory name matches the intended project name.
-
scripts/init_from_template.shwas run from the project root. -
.template-initializedexists. - The Python package under
src/has the expected name. -
.envwas created from.env.example. - Local tests pass.
- Lint passes.
- Docker tests pass if Docker will be used.
Commands:
cp .env.example .env
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
scripts/test.sh full local
scripts/lint.shOptional Docker validation:
PROJECT_NAME=chemistry_mock_site scripts/test.sh full docker-dev
PROJECT_NAME=chemistry_mock_site scripts/test.sh full docker-qa