Python Starter
Automatically configures formatter and linter when initializing Python projects.
Workflow
- Environment Detection and Selection
- Use UV if uv.lock file exists or uv command is available - Use Poetry if [tool.poetry] section exists in pyproject.toml - If no environment is configured, recommend uv - Otherwise use venv - Ask the user if uncertain
- Install ruff
- Install ruff as dev dependency based on selected environment - Use commands (avoid writing code directly) - Reference: environment-setup.md
- Configure pyproject.toml
- Create pyproject.toml if it doesn't exist - Add ruff configuration (see pyproject-toml-examples.md for default settings) - Template: assets/pyproject.toml.template
- Install pytest
- Install pytest as dev dependency based on selected environment - Use commands (avoid writing code directly)
- Type Checking Setup (Optional)
- Ask the user if they want ty setup - Install ty as dev dependency if needed - Add ty configuration to pyproject.toml - Reference: pyproject-toml-examples.md
- Pre-commit Setup (Optional)
- Ask the user if they want pre-commit setup - Install pre-commit and create .pre-commit-config.yaml if needed - Reference: pre-commit-setup.md - Template: assets/.pre-commit-config.yaml.template
- VSCode Settings Suggestion
- Suggest creating .vscode/settings.json when using VSCode - Include ruff and ty (if configured) settings - Reference: vscode-settings.md - Template: assets/.vscode-settings.json.template
- Create.gitignore
- Create .gitignore if it doesn't exist - Include common Python ignores for virtual environments, cache files, build artifacts, IDE files, and OS files - Template: assets/.gitignore.template
Principles
- Command-first: Use commands whenever possible instead of writing code directly
- Use pyproject.toml: Store all configuration in
pyproject.toml - Dev dependencies: Install ruff, pytest, ty, and pre-commit as dev dependencies
- User confirmation: Confirm with user for environment selection, ty, and pre-commit before proceeding
References
- Environment setup: references/environment-setup.md
- pyproject.toml examples: references/pyproject-toml-examples.md
- Pre-commit setup: references/pre-commit-setup.md
- VSCode settings: references/vscode-settings.md