|
| 1 | +Initialize a new Python project from this template repository. |
| 2 | + |
| 3 | +Transform this generic template into a personalized starting point for your Python project by: |
| 4 | + |
| 5 | +### Workflow |
| 6 | + |
| 7 | +1. **Collect Project Information** |
| 8 | + - Get current git remote URL to extract owner and repository name |
| 9 | + - Prompt user for project name if different from repository name |
| 10 | + - Validate project name follows Python package naming conventions |
| 11 | + |
| 12 | +2. **Update Project Structure** |
| 13 | + - Rename `src/template_python/` directory to `src/{project_name}/` |
| 14 | + - Update all file references from `template_python` to `{project_name}` |
| 15 | + - Replace `template-python` with `{project-name}` in hyphenated contexts |
| 16 | + |
| 17 | +3. **Update Configuration Files** |
| 18 | + - Update `pyproject.toml`: |
| 19 | + - Change project name from "template-python" to "{project-name}" |
| 20 | + - Update description placeholder |
| 21 | + - Update author information from git config |
| 22 | + - Update repository URLs to match new project |
| 23 | + - Update script entry points |
| 24 | + - Update `README.md`: |
| 25 | + - Replace title from "Python Project Template" to "{Project Name}" |
| 26 | + - Update repository URLs and clone commands |
| 27 | + - Update package import examples |
| 28 | + - Remove template-specific content |
| 29 | + |
| 30 | +4. **Update Source Code** |
| 31 | + - Update `src/{project_name}/__init__.py` |
| 32 | + - Update any import statements in test files |
| 33 | + - Update entry point script references |
| 34 | + |
| 35 | +5. **Git Operations** |
| 36 | + - Stage all changes |
| 37 | + - Create initial commit: "feat: initialize project from template" |
| 38 | + - Optionally set up remote origin if not already configured |
| 39 | + |
| 40 | +6. **Environment Setup and Validation** |
| 41 | + - Check for `uv` command availability (exit with error if not found) |
| 42 | + - Run `uv sync --all-extras` to install all dependencies including dev dependencies |
| 43 | + - Activate virtual environment with `source .venv/bin/activate` |
| 44 | + |
| 45 | +7. **Quality Checks** |
| 46 | + - Run `pytest` to execute test suite |
| 47 | + - Run `ruff check` for linting validation |
| 48 | + - Run `ruff format` for code formatting |
| 49 | + - Run `basedpyright` for type checking |
| 50 | + - Report success only if all commands pass (exit code 0) |
| 51 | + |
| 52 | +### Validation |
| 53 | + |
| 54 | +- Ensure project name is valid Python package name (lowercase, underscores only) |
| 55 | +- Verify all file references have been updated correctly |
| 56 | +- Validate pyproject.toml syntax |
| 57 | +- Check `uv` command is available on system |
| 58 | +- Ensure virtual environment is created and activated successfully |
| 59 | +- Validate all dependencies install without errors |
| 60 | +- Verify tests pass (pytest exit code 0) |
| 61 | +- Ensure code passes linting (ruff check exit code 0) |
| 62 | +- Verify code formatting is correct (ruff format exit code 0) |
| 63 | +- Confirm type checking passes (basedpyright exit code 0) |
| 64 | + |
| 65 | +### Notes |
| 66 | + |
| 67 | +- The command should be run immediately after cloning the template |
| 68 | +- It assumes the current directory is the root of the template repository |
| 69 | +- Git repository should already be initialized |
| 70 | +- User should have git configured with name and email |
| 71 | +- Requires `uv` package manager to be installed (https://docs.astral.sh/uv/) |
| 72 | +- The command will create a virtual environment and install all dependencies |
| 73 | +- All quality checks must pass for the command to report success |
| 74 | +- Use `--skip-install` flag to skip environment setup if only doing file transformations |
| 75 | + |
| 76 | +### Arguments |
| 77 | + |
| 78 | +``` |
| 79 | +$ARGUMENTS |
| 80 | +``` |
| 81 | + |
| 82 | +Optional arguments: |
| 83 | +- `--project-name`: Override project name (default: use git repository name) |
| 84 | +- `--author-name`: Override author name (default: use git config user.name) |
| 85 | +- `--author-email`: Override author email (default: use git config user.email) |
| 86 | +- `--description`: Set project description |
| 87 | +- `--skip-git`: Don't create initial commit |
| 88 | +- `--skip-install`: Skip environment setup and quality checks (steps 6-7) |
0 commit comments