From 0a7d40ae5f29ea71a801cee87755472b845ff68b Mon Sep 17 00:00:00 2001 From: Austin Gregg-Smith Date: Sun, 1 Mar 2026 12:56:59 +0000 Subject: [PATCH 1/6] add shellcheck --- .pre-commit-config.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ae2c7df..d562951 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,6 +48,12 @@ repos: # Run the formatter. - id: ruff-format types_or: [ python, pyi ] + # Shell script linter + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.10.0.1 + hooks: + - id: shellcheck + # Checks for spelling mistakes - repo: https://github.com/codespell-project/codespell rev: v2.3.0 From 1582f29ab38a68066f5ab3397b15c8dc8d493a34 Mon Sep 17 00:00:00 2001 From: Austin Gregg-Smith Date: Sun, 1 Mar 2026 13:06:18 +0000 Subject: [PATCH 2/6] add shellcheck --- .claude/hooks/SessionStart | 1 + .devcontainer/claude-code/install.sh | 4 +++- .pre-commit-config.yaml | 9 ++++++--- scripts/launch_vscode.sh | 6 ++++-- scripts/setup_host.sh | 6 ++++-- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.claude/hooks/SessionStart b/.claude/hooks/SessionStart index 97214ae..f5a1c13 100755 --- a/.claude/hooks/SessionStart +++ b/.claude/hooks/SessionStart @@ -15,6 +15,7 @@ if ! command -v pixi &> /dev/null; then export PATH="$HOME/.pixi/bin:$PATH" # Source bashrc to get pixi in PATH (if bashrc was updated) + # shellcheck disable=SC1091 [ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc" echo "✅ Pixi installed successfully" diff --git a/.devcontainer/claude-code/install.sh b/.devcontainer/claude-code/install.sh index 020018f..a5c47b3 100755 --- a/.devcontainer/claude-code/install.sh +++ b/.devcontainer/claude-code/install.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -eu # Claude Code CLI Local Feature Install Script @@ -83,6 +83,7 @@ install_claude_code() { # Add pixi bin path to user's profile if not already there local profile="$TARGET_HOME/.profile" + # shellcheck disable=SC2016 local pixi_path_line='export PATH="$HOME/.pixi/bin:$PATH"' if [ -f "$profile" ] && ! grep -q '\.pixi/bin' "$profile"; then echo "$pixi_path_line" >> "$profile" @@ -93,6 +94,7 @@ install_claude_code() { # Workaround: pixi trampoline fails for bash scripts, so add env bin directly # This conditionally adds the path only if the env exists + # shellcheck disable=SC2016 local env_path_line='[ -d "$HOME/.pixi/envs/claude-shim/bin" ] && export PATH="$HOME/.pixi/envs/claude-shim/bin:$PATH"' if [ -f "$profile" ] && ! grep -q 'pixi/envs/claude-shim' "$profile"; then echo "# Workaround: pixi trampoline fails for bash scripts" >> "$profile" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d562951..bc83d51 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,11 +48,14 @@ repos: # Run the formatter. - id: ruff-format types_or: [ python, pyi ] - # Shell script linter - - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.10.0.1 + # Shell script linter (uses shellcheck from pixi) + - repo: local hooks: - id: shellcheck + name: shellcheck + language: system + entry: pixi run shellcheck + types: [shell] # Checks for spelling mistakes - repo: https://github.com/codespell-project/codespell diff --git a/scripts/launch_vscode.sh b/scripts/launch_vscode.sh index fa6b029..8b282d7 100755 --- a/scripts/launch_vscode.sh +++ b/scripts/launch_vscode.sh @@ -25,14 +25,16 @@ if [ ! -d "$VENV_DIR" ]; then echo "Creating virtual environment in $VENV_DIR..." python3 -m venv "$VENV_DIR" echo "Activating the virtual environment..." - source $VENV_DIR/bin/activate + # shellcheck disable=SC1091 + source "$VENV_DIR/bin/activate" echo "Installing deps rocker..." pip install deps-rocker pixi-rocker rockervsc echo "Virtual environment setup and deps rocker installation complete." else echo "Virtual environment already exists in $VENV_DIR." echo "Activating the existing virtual environment..." - source $VENV_DIR/bin/activate + # shellcheck disable=SC1091 + source "$VENV_DIR/bin/activate" fi rockervsc diff --git a/scripts/setup_host.sh b/scripts/setup_host.sh index 35e8117..0030271 100755 --- a/scripts/setup_host.sh +++ b/scripts/setup_host.sh @@ -6,7 +6,7 @@ # https://docs.docker.com/engine/install/ubuntu/ #remove incorrect docker -for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done +for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove "$pkg"; done # Add Docker's official GPG key: sudo apt update @@ -16,6 +16,7 @@ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyring sudo chmod a+r /etc/apt/keyrings/docker.asc # Add the repository to Apt sources: +# shellcheck disable=SC1091 echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ @@ -52,11 +53,12 @@ echo "you may need to restart your machine" #INSTALL PIXI curl -fsSL https://pixi.sh/install.sh | bash +# shellcheck disable=SC2016 echo 'eval "$(pixi completion --shell bash)"' >> ~/.bashrc #INSTALL UV curl -LsSf https://astral.sh/uv/install.sh | sh sudo groupadd docker -sudo usermod -aG docker $USER +sudo usermod -aG docker "$USER" newgrp docker || true From 88da858aab30133b63c20c7af40c15ab8138e6ef Mon Sep 17 00:00:00 2001 From: Austin Gregg-Smith Date: Sun, 1 Mar 2026 13:08:12 +0000 Subject: [PATCH 3/6] turn off common utils and docker-in-docker by default --- .devcontainer/devcontainer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 03641c7..591412f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -12,8 +12,8 @@ "features": { "./claude-code": {}, - "ghcr.io/devcontainers/features/docker-in-docker:2": {}, - "ghcr.io/devcontainers/features/common-utils:2": {} + // "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + // "ghcr.io/devcontainers/features/common-utils:2": {} }, "initializeCommand": ".devcontainer/claude-code/init-host.sh", From 7eb3b1d6887f948b627ab4680ff9cd835384cf26 Mon Sep 17 00:00:00 2001 From: Austin Gregg-Smith Date: Sun, 1 Mar 2026 13:11:54 +0000 Subject: [PATCH 4/6] add pipefile to scripts --- .claude/hooks/SessionStart | 2 +- .devcontainer/claude-code/install.sh | 2 +- .pre-commit-config.yaml | 4 ++-- scripts/launch_vscode.sh | 2 +- scripts/rename_project.sh | 1 + scripts/setup_host.sh | 1 + scripts/update_from_template.sh | 1 + 7 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.claude/hooks/SessionStart b/.claude/hooks/SessionStart index f5a1c13..215bf16 100755 --- a/.claude/hooks/SessionStart +++ b/.claude/hooks/SessionStart @@ -2,7 +2,7 @@ # SessionStart hook for Claude Code online environment # This script sets up the Python development environment using pixi -set -e +set -eo pipefail echo "🚀 Setting up Python Template environment..." diff --git a/.devcontainer/claude-code/install.sh b/.devcontainer/claude-code/install.sh index a5c47b3..a52d2b4 100755 --- a/.devcontainer/claude-code/install.sh +++ b/.devcontainer/claude-code/install.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -eu +set -euo pipefail # Claude Code CLI Local Feature Install Script # Installs Claude Code via pixi and sets up configuration directories diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bc83d51..d518641 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,13 +48,13 @@ repos: # Run the formatter. - id: ruff-format types_or: [ python, pyi ] - # Shell script linter (uses shellcheck from pixi) + # Shell script linter (tries system shellcheck, falls back to pixi) - repo: local hooks: - id: shellcheck name: shellcheck language: system - entry: pixi run shellcheck + entry: bash -c 'if command -v shellcheck >/dev/null 2>&1; then shellcheck "$@"; else pixi run shellcheck "$@"; fi' -- types: [shell] # Checks for spelling mistakes diff --git a/scripts/launch_vscode.sh b/scripts/launch_vscode.sh index 8b282d7..18e375e 100755 --- a/scripts/launch_vscode.sh +++ b/scripts/launch_vscode.sh @@ -1,5 +1,5 @@ #! /bin/bash -set -e +set -eo pipefail export COMPOSE_DOCKER_CLI_BUILD=1 export DOCKER_BUILDKIT=1 diff --git a/scripts/rename_project.sh b/scripts/rename_project.sh index ce4847c..c1b6590 100755 --- a/scripts/rename_project.sh +++ b/scripts/rename_project.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -eo pipefail # Escape characters special in sed replacement strings (\, &, /) escape_sed() { printf '%s\n' "$1" | sed 's/[\\&/]/\\&/g'; } diff --git a/scripts/setup_host.sh b/scripts/setup_host.sh index 0030271..e2726cd 100755 --- a/scripts/setup_host.sh +++ b/scripts/setup_host.sh @@ -1,4 +1,5 @@ #! /bin/bash +set -eo pipefail #Sets up docker, nvidia docker git-lfs and rocker which are used to clone and setup docker containers diff --git a/scripts/update_from_template.sh b/scripts/update_from_template.sh index d8683e7..96d4fb8 100755 --- a/scripts/update_from_template.sh +++ b/scripts/update_from_template.sh @@ -1,4 +1,5 @@ #! /bin/bash +set -eo pipefail git config --global pull.rebase false git remote add template https://github.com/blooop/python_template.git From b1d7630df6357406aff3915681cea66eacad9fe3 Mon Sep 17 00:00:00 2001 From: Austin Gregg-Smith Date: Sun, 1 Mar 2026 13:16:18 +0000 Subject: [PATCH 5/6] update pixi.lock --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d518641..b01e7e7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,13 +48,13 @@ repos: # Run the formatter. - id: ruff-format types_or: [ python, pyi ] - # Shell script linter (tries system shellcheck, falls back to pixi) + # Shell script linter - repo: local hooks: - id: shellcheck name: shellcheck language: system - entry: bash -c 'if command -v shellcheck >/dev/null 2>&1; then shellcheck "$@"; else pixi run shellcheck "$@"; fi' -- + entry: pixi run shellcheck types: [shell] # Checks for spelling mistakes From e6af7f3621e779d7840246c7cc3a361ec0076834 Mon Sep 17 00:00:00 2001 From: Austin Gregg-Smith Date: Sun, 1 Mar 2026 13:19:14 +0000 Subject: [PATCH 6/6] fix shellcheck pre-commit hook to work in CI The local system hook using `pixi run shellcheck` fails in CI because pixi is not available in the prek-action environment. Switch to the official shellcheck-precommit repo which bundles its own binary. --- .pre-commit-config.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b01e7e7..2f838de 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,13 +49,10 @@ repos: - id: ruff-format types_or: [ python, pyi ] # Shell script linter - - repo: local + - repo: https://github.com/koalaman/shellcheck-precommit + rev: v0.11.0 hooks: - id: shellcheck - name: shellcheck - language: system - entry: pixi run shellcheck - types: [shell] # Checks for spelling mistakes - repo: https://github.com/codespell-project/codespell