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
21 changes: 20 additions & 1 deletion .claude/settings/permissions/bash.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,17 @@
"Bash(tail *)",
// Search
"Bash(rg *)",
// Research
"Bash(gh issue list *)",
"Bash(gh pr view *)",
"Bash(gh pr diff *)"
],
"ask": [
"Bash(gh *)", // let's hold off before we let it use the github CLI in any free running allow mode...I don't want it somehow approving PRs with the user's credentials
// let's hold off before we let it use the github CLI in any free running allow mode...I don't want it somehow approving PRs with the user's credentials
"Bash(gh repo *)",
"Bash(gh release *)",
"Bash(gh secret *)",
"Bash(gh ruleset *)",
"Bash(aws *)", // let's hold off before we let it use AWS CLI in any free running allow mode. We need to be very sure we don't have any access to staging or production credentials in our dev environment (...which we shouldn't...but we need to double check that or consider any other safeguards first)
"Bash(curl *)",
"Bash(ln *)",
Expand All @@ -85,6 +93,17 @@
"deny": [
// Exceptions to generally allowed AI tooling
"Bash(bd init*)", // we need to control the init process, don't let AI do that in the background
// Github
// Claude should not ever interfere with the PR process, that is how we gate AI's work
"Bash(gh pr create *)",
"Bash(gh pr edit *)",
"Bash(gh pr ready *)",
"Bash(gh pr review *)",
"Bash(gh pr merge *)",
"Bash(gh pr close *)",
"Bash(gh pr comment *)",
"Bash(gh pr update-branch *)",

Comment on lines +96 to +106
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Consider adding gh pr reopen * to the deny list.

The deny list comprehensively blocks PR mutation commands, but gh pr reopen * is missing. Reopening a closed PR is a mutating operation that could interfere with the PR process, which contradicts the stated intent in the comment on lines 97-98.

Suggested fix
       "Bash(gh pr close *)",
       "Bash(gh pr comment *)",
       "Bash(gh pr update-branch *)",
+      "Bash(gh pr reopen *)",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Github
// Claude should not ever interfere with the PR process, that is how we gate AI's work
"Bash(gh pr create *)",
"Bash(gh pr edit *)",
"Bash(gh pr ready *)",
"Bash(gh pr review *)",
"Bash(gh pr merge *)",
"Bash(gh pr close *)",
"Bash(gh pr comment *)",
"Bash(gh pr update-branch *)",
// Github
// Claude should not ever interfere with the PR process, that is how we gate AI's work
"Bash(gh pr create *)",
"Bash(gh pr edit *)",
"Bash(gh pr ready *)",
"Bash(gh pr review *)",
"Bash(gh pr merge *)",
"Bash(gh pr close *)",
"Bash(gh pr comment *)",
"Bash(gh pr update-branch *)",
"Bash(gh pr reopen *)",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/settings/permissions/bash.jsonc around lines 96 - 106, The deny list
for GitHub PR commands omits the mutating action to reopen PRs; add the entry
"Bash(gh pr reopen *)" alongside the other denied commands (e.g., "Bash(gh pr
create *)", "Bash(gh pr edit *)") so that reopen operations are blocked as
intended; update the permissions array to include this exact string to ensure
"gh pr reopen" is treated as a denied Bash action.

// Destructive File Operations
"Bash(chmod -R *)",
"Bash(chown -R *)",
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@
"initializeCommand": "sh .devcontainer/initialize-command.sh",
"onCreateCommand": "sh .devcontainer/on-create-command.sh",
"postStartCommand": "sh .devcontainer/post-start-command.sh"
// Devcontainer context hash (do not manually edit this, it's managed by a pre-commit hook): 01a288c4 # spellchecker:disable-line
// Devcontainer context hash (do not manually edit this, it's managed by a pre-commit hook): 5ecc43b1 # spellchecker:disable-line
}
17 changes: 17 additions & 0 deletions .devcontainer/manual-setup-deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
default=False,
help="Allow uv to install new versions of Python on the fly. This is typically only needed when instantiating the copier template.",
)
_ = parser.add_argument(
"--skip-installing-pulumi-cli",
action="store_true",
default=False,
help="Do not install the Pulumi CLI even if the lock file references it",
)


class PackageManager(str, enum.Enum):
Expand Down Expand Up @@ -127,6 +133,17 @@ def main():
check=True,
env=uv_env,
)
if (
not generate_lock_file_only
and not args.skip_installing_pulumi_cli
and platform.system() == "Linux"
and env.lock_file.exists()
and '"pulumi"' in env.lock_file.read_text()
):
_ = subprocess.run(
["sh", str(REPO_ROOT_DIR / ".devcontainer" / "install-pulumi-cli.sh"), str(env.lock_file)],
check=True,
)
elif env.package_manager == PackageManager.PNPM:
pnpm_command = ["pnpm", "install", "--dir", str(env.path)]
if env_check_lock:
Expand Down
9 changes: 6 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ This project is a Copier template used to generate other copier templates. It is

## Testing

- Always run tests with an explicit path (e.g. uv run pytest tests/unit) — test runners discover all types by default.
- Always run tests with an explicit path (e.g. uv run pytest tests/unit) — test runners discover all types (unit, integration, E2E...) by default.
- When iterating on a single test, run that test in isolation first and confirm it is in the expected state (red or green) before widening to the full suite. Use the most targeted invocation available: a specific test function for Python (e.g. `uv run pytest path/to/test.py::test_name --no-cov`) or a file path and name filter for TypeScript (e.g. `pnpm test-unit -- path/to/test.spec.ts -t "test name" --no-coverage`). Only run the full suite once the target test behaves as expected.
- Test coverage requirements are usually at 100%, so when running a subset of tests, always disable test coverage to avoid the test run failing for insufficient coverage.
- Avoid magic values in comparisons in tests in all languages (like ruff rule PLR2004 specifies)
- Prefer using random values in tests rather than arbitrary ones (e.g. the faker library, uuids, random.randint) when possible. For enums, pick randomly rather than hardcoding one value.
Expand All @@ -26,11 +27,12 @@ This project is a Copier template used to generate other copier templates. It is

### Python Testing

- When using `mocker.spy` on a class-level method (including inherited ones), the spy records the unbound call, so assertions need `ANY` as the first argument to match self: `spy.assert_called_once_with(ANY, expected_arg)`
- When using `mocker.spy` on a class-level method (including inherited ones), the spy records the unbound call, so assertions need `ANY` as the first argument to match self: `spy.assert_called_once_with(ANY, expected_arg)`
- Before writing new mock/spy helpers, check the `tests/unit/` folder for pre-built helpers in files like `fixtures.py` or `*mocks.py`
- When a test needs a fixture only for its side effects (not its return value), use `@pytest.mark.usefixtures(fixture_name.__name__)` instead of adding an unused parameter with a noqa comment
- Use `__name__` instead of string literals when referencing functions/methods (e.g., `mocker.patch.object(MyClass, MyClass.method.__name__)`, `pytest.mark.usefixtures(my_fixture.__name__)`). This enables IDE refactoring tools to catch renames.
- When using the faker library, prefer the pytest fixture (provided by the faker library) over instantiating instances of Faker.
- **Choosing between cassettes and mocks:** At the layer that directly wraps an external API or service, strongly prefer VCR cassette-recorded interactions (via pytest-recording/vcrpy) — they capture real HTTP traffic and verify the wire format, catching integration issues that mocks would miss. At layers above that (e.g. business logic, route handlers), mock the wrapper layer instead (e.g. `mocker.patch.object(ThresholdsRepository, ...)`) — there is no value in re-testing the HTTP interaction from higher up.
- **Never hand-write VCR cassette YAML files.** Cassettes must be recorded from real HTTP interactions by running the test once with `--record-mode=once` against a live external service: `uv run pytest --record-mode=once <test path> --no-cov`. The default mode is `none` — a missing cassette will cause an error, which is expected until recorded.
- **Never hand-edit syrupy snapshot files.** Snapshots are auto-generated — to create or update them, run `uv run pytest --snapshot-update <test path> --no-cov`. A missing snapshot causes the test to fail, which is expected until you run with `--snapshot-update`. When a snapshot mismatch occurs, fix the code if the change was unintentional; run `--snapshot-update` if it was intentional.
- **Never hand-write or hand-edit pytest-reserial `.jsonl` recording files.** Recordings must be captured from real serial port traffic by running the test with `--record` while the device is connected: `uv run pytest --record <test path> --no-cov`. The default mode replays recordings — a missing recording causes an error, which is expected until recorded against a live device.
Expand All @@ -49,7 +51,8 @@ This project is a Copier template used to generate other copier templates. It is
- For frontend tests, run commands via `pnpm` scripts from `frontend/package.json` — never invoke tools directly (not pnpm exec <tool>, npx <tool>, etc.). ✅ pnpm test-unit ❌ pnpm vitest ... or npx vitest ...
- For linting and type-checking, prefer `pre-commit run <hook-id>` over invoking tools directly — this matches the permission allow-list and mirrors what CI runs. Key hook IDs: `typescript-check`, `eslint`, `pyright`, `ruff`, `ruff-format`.
- Never rely on IDE diagnostics for ruff warnings — the IDE may not respect the project's ruff.toml config. Run `pre-commit run ruff -a` to get accurate results.
- When running terminal commands, execute exactly one command per tool call. Do not chain commands with &&, ||, ;, or & — this prohibition has no exceptions, even for `cd && ...` patterns. Use absolute paths instead of `cd` to avoid needing to chain. Pipes (|) are allowed for output transformation (e.g., head, tail, grep). If two sequential commands are needed, run them in separate tool calls. Chained commands break the permission allow-list matcher and cause unnecessary permission prompts
- When running terminal commands, execute exactly one command per tool call. Do not chain commands with &&, ||, ;, or & — this prohibition has no exceptions, even for `cd && ...` patterns. Use `cd` to change to the directory you want before running the command, avoiding the need to chain. Pipes (|) are allowed for output transformation (e.g., head, tail, grep). If two sequential commands are needed, run them in separate tool calls. Chained commands break the permission allow-list matcher and cause unnecessary permission prompts
- Never use `pnpm --prefix <path>` or `uv --directory <path>` to target a different directory — these flags break the permission allow-list matcher the same way chained `cd &&` commands do. Instead, rely on the working directory already being correct (the cwd persists between Bash tool calls), or issue a plain `cd <path>` as a separate prior tool call to reposition before running the command.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Resolve contradiction with Line 54 about cd usage.

Line 55 allows a separate cd <path> call, but Line 54 says to use absolute paths instead of cd. Please reconcile into one consistent rule so agents don’t get conflicting directives.

Based on learnings: "When running terminal commands... Use absolute paths instead of cd to avoid needing to chain."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@AGENTS.md` at line 55, Update the contradictory guidance so there's one rule:
prohibit using `pnpm --prefix <path>`, `uv --directory <path>`, or `cd &&`
chains and require using absolute paths (or commands that include absolute
paths) when running terminal commands; remove the allowance that permits a
separate `cd <path>` call and instead state that the working directory should be
set outside agent commands or ensured by the caller, and that the cwd
persistence between Bash tool calls may not be relied on—always prefer absolute
paths to avoid breaking the permission allow-list matcher.

- Never use backslash line continuations in shell commands — always write the full command on a single line. Backslashes break the permission allow-list matcher.
- **Never manually edit files in any `generated/` folder.** These files are produced by codegen tooling (typically Kiota) and any manual changes will be overwritten. If a generated file needs to change, update the source (e.g. the OpenAPI schema) and re-run the generator.

Expand Down
7 changes: 6 additions & 1 deletion template/.github/actions/install_deps/action.yml.jinja-base
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ inputs:
description: Whether to skip updating the hash when running manual-setup-deps.py
default: true
required: false
skip-installing-pulumi-cli:
type: boolean
description: Whether to skip installing the Pulumi CLI even if the lock file references it
default: true
required: false


runs:
Expand Down Expand Up @@ -83,5 +88,5 @@ runs:
- name: Install dependencies
# the funky syntax is github action ternary
if: ${{ inputs.install-deps }}
run: python .devcontainer/manual-setup-deps.py ${{ inputs.python-version == 'notUsing' && '--no-python' || '' }} ${{ inputs.node-version == 'notUsing' && '--no-node' || '' }} ${{ inputs.skip-updating-devcontainer-hash && '--skip-updating-devcontainer-hash' || '' }}
run: python .devcontainer/manual-setup-deps.py ${{ inputs.python-version == 'notUsing' && '--no-python' || '' }} ${{ inputs.node-version == 'notUsing' && '--no-node' || '' }} ${{ inputs.skip-updating-devcontainer-hash && '--skip-updating-devcontainer-hash' || '' }} ${{ inputs.skip-installing-pulumi-cli && '--skip-installing-pulumi-cli' || '' }}
shell: pwsh{% endraw %}
1 change: 1 addition & 0 deletions template/.github/workflows/pre-commit.yaml.jinja-base
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
python-version: ${{ inputs.python-version }}
node-version: ${{ inputs.node-version }}
skip-installing-ssm-plugin-manager: true
skip-installing-pulumi-cli: true

- name: Set up mutex # Github concurrency management is horrible, things get arbitrarily cancelled if queued up. So using mutex until github fixes itself. When multiple jobs are modifying cache at once, weird things can happen. possible issue is https://github.com/actions/toolkit/issues/658
if: ${{ runner.os != 'Windows' }} # we're just gonna have to YOLO on Windows, because this action doesn't support it yet https://github.com/ben-z/gh-action-mutex/issues/14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ jobs:
uses: ./.github/actions/install_deps
with:
python-version: ${{ inputs.PYTHON_VERSION }}
skip-installing-pulumi-cli: true # at the moment, we're more specifically installing the Pulumi CLI just in the target directory inside the pulumi_ephemeral_deploy action

- name: Download Artifact
uses: actions/download-artifact@{% endraw %}{{ gha_download_artifact }}{% raw %}
Expand Down