Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/etc/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ cookiecutter
dependabot
digestabot
dockerhub
envrc
htmlcov
pylance
pythonpath
Expand Down
37 changes: 8 additions & 29 deletions docs/ai-ide-support.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,25 @@
# AI IDE Support

The AI-Native Python template includes configuration files to work seamlessly with AI-powered development tools.
The AI-Native Python template automatically configures AI-powered development tools during project generation.

[← Back to Documentation Index](index.md)


## Tool-agnostic configurations
## Automatic Configuration

### .mcp.json
When you generate a new project, the post-generation hook automatically detects which IDEs and AI assistants you have installed and creates appropriate configuration files:

Model Context Protocol configuration pre-set to integrate with:
- Model Context Protocol (MCP) configuration for [Zenable](https://zenable.io) and other MCP servers (if supported tools are detected)
- IDE-specific configuration files based on what's installed (Claude, GitHub Copilot, Cursor, etc.)
- Project-specific context and guidelines tailored to your project

- [Zenable](https://zenable.io)'s MCP server
- [Context7](https://context7.com/)'s MCP server

## Specific IDE configurations

### Claude Code

Every generated project includes a `CLAUDE.md` file with:
These configurations are dynamically generated based on your installed IDEs and project settings, and include:

- Project-specific context and guidelines
- Technology stack information
- Code style rules and patterns
- Common tasks and workflows

### GitHub Copilot Configuration

The template includes `.github/copilot-instructions.md` with:

- Project-specific context for GitHub Copilot
- Code conventions and patterns
- Testing requirements and workflow
- Testing requirements and patterns
- Security considerations
- Common code patterns and examples
- Task automation commands

### Cursor IDE Configuration

The template includes `.cursor/rules/` directory with:

- `project.mdc`: Always-active rules with project info, tech stack, and key commands
- `testing.mdc`: Auto-attached rules for test files with testing guidelines and patterns

For more details on testing configuration and practices, see the [Testing Guide](testing.md).
6 changes: 1 addition & 5 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,9 @@ After your project is generated, you are able to make any changes you'd like. He

### Environment Variables

Create or modify the `.envrc` file in your project root:
Set environment variables for development:

```bash
# API Keys
export ZENABLE_API_KEY="your-api-key-here"

# Development settings
export PYTHONPATH="${PWD}/src:${PYTHONPATH}"
export UV_PYTHON_PREFERENCE="only-system"
```
Expand Down
6 changes: 2 additions & 4 deletions docs/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ The `post_gen_project.py` hook runs after project generation to:
2. Create the project's initial commit
3. Set up GitHub remote (if credentials available)
4. Generate a fully up-to-date `uv.lock` file
5. Create an `.envrc` with API keys
6. Run `task init` to install dependencies
7. Push to GitHub and create an initial release
5. Run `task init` to install dependencies
6. Push to GitHub and create an initial release

### Configuration

Environment variables can be set before running cookiecutter to modify hook behavior:

- `SKIP_GIT_PUSH=true` - Skip automatic Git push
- `RUN_POST_HOOK=false` - Skip the post-generation hook entirely (not recommended)
- `ZENABLE_API_KEY="..."` - Auto-populate API key in .envrc

For more environment variable options, see the [Optional Setup Guide](optional-setup.md#environment-variable-configuration).

Expand Down
6 changes: 1 addition & 5 deletions docs/optional-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,4 @@ uvx --with gitpython cookiecutter git+ssh://git@github.com/zenable-io/ai-native-

## Environment Variable Configuration

Generated projects include an `.envrc` file for environment-specific settings. API keys can be pre-populated during project generation by setting environment
variables before running cookiecutter (see the [Hooks Guide](hooks.md#configuration)).

To request support for additional API keys, please [open an issue](https://github.com/Zenable-io/ai-native-python/issues/new) or [pull
request](../CONTRIBUTING.md)!
Set environment variables before running cookiecutter to modify hook behavior (see the [Hooks Guide](hooks.md#configuration)).
33 changes: 0 additions & 33 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,34 +122,6 @@ def write_context(*, context: dict) -> None:
yaml.dump(context, file)


def populate_envrc() -> None:
"""Create and populate the .envrc file with API key."""
envrc_path = Path(".envrc")
zenable_api_key = os.environ.get("ZENABLE_API_KEY")

if zenable_api_key:
envrc_path.write_text(f'export API_KEY="{zenable_api_key}"\n')
else:
envrc_path.write_text('export API_KEY="<YOUR_ZENABLE_API_KEY>"\n')

# Restrict permissions to read-only, by the owner/current user
envrc_path.chmod(0o600)


def notify_envrc() -> None:
zenable_api_key = os.environ.get("ZENABLE_API_KEY")
print("\n" + "=" * 70)
print("NOTE: Environment Configuration")
print("=" * 70)
print("\nA .envrc file has been created in your project directory")
print("To use services that require API keys, update the .envrc file with your keys")
print("The .envrc file has already been added to your .gitignore")
print("=" * 70 + "\n")
if zenable_api_key:
print("Your ZENABLE_API_KEY has been automatically populated from the environment")
print("=" * 70 + "\n")


def notify_dockerhub_secrets() -> None:
"""Notify user about required Docker Hub secrets for releases."""
# We no longer need this once https://github.com/docker/roadmap/issues/314 is available
Expand Down Expand Up @@ -311,18 +283,13 @@ def run_post_gen_hook():
check=True,
)

# Create .envrc file with API key template
populate_envrc()

# Run the initial setup step automatically so pre-commit hooks, etc. are pre-installed. However, if it fails, don't fail the overall repo generation
# (i.e. check=False)
subprocess.run(["task", "init"], check=False, capture_output=True)

# Notify about Docker Hub secrets if Docker Hub publishing is enabled
if cookiecutter_context.get("dockerhub") == "yes":
notify_dockerhub_secrets()

notify_envrc()
except subprocess.CalledProcessError as error:
stdout = error.stdout.decode("utf-8") if error.stdout else "No stdout"
stderr = error.stderr.decode("utf-8") if error.stderr else "No stderr"
Expand Down
2 changes: 0 additions & 2 deletions {{cookiecutter.project_name|replace(" ", "")}}/.gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
.mcp.json
.task/*
.lycheecache
sbom.*.json
vulns.*.json
license-check.*.json
{{ cookiecutter.github_org }}_{{ cookiecutter.project_slug }}_*_*.tar
.envrc

# Created by https://www.toptal.com/developers/gitignore/api/vim,emacs,visualstudiocode,python,macos,windows
# Edit at https://www.toptal.com/developers/gitignore?templates=vim,emacs,visualstudiocode,python,macos,windows
Expand Down
12 changes: 0 additions & 12 deletions {{cookiecutter.project_name|replace(" ", "")}}/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ tasks:
# Sync dependencies with uv
- uv sync --frozen --all-extras

init-direnv:
desc: Sets up direnv locally
internal: true
status:
- '{{ '{{if eq .GITHUB_ACTIONS "true"}}exit 0{{end}}' }}'
cmds:
- task: brew-install
vars:
TOOLS: direnv
- direnv allow

init-pre-commit:
desc: Install the pre-commit hooks
internal: true
Expand Down Expand Up @@ -77,7 +66,6 @@ tasks:
desc: Initialize the repo for local use; intended to be run after git clone
cmds:
- task: init-uv
- task: init-direnv
- task: init-pre-commit
- task: init-docker-multiplatform

Expand Down
Loading