bq-inspector 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bq_inspector-0.1.0/.agents/skills/build-and-fix/SKILL.md +40 -0
- bq_inspector-0.1.0/.agents/skills/check-directory-structure/SKILL.md +84 -0
- bq_inspector-0.1.0/.agents/skills/codeql-fix/SKILL.md +78 -0
- bq_inspector-0.1.0/.agents/skills/codeql-fix/assets/code-scanning-config.template.yml +17 -0
- bq_inspector-0.1.0/.agents/skills/codeql-fix/references/code-scanning-config.md +12 -0
- bq_inspector-0.1.0/.agents/skills/codeql-fix/scripts/render-code-scanning-config.sh +116 -0
- bq_inspector-0.1.0/.agents/skills/deep-problem-solving/README.md +19 -0
- bq_inspector-0.1.0/.agents/skills/deep-problem-solving/SKILL.md +100 -0
- bq_inspector-0.1.0/.agents/skills/deep-problem-solving/references/full-report-template.md +75 -0
- bq_inspector-0.1.0/.agents/skills/initialize-project/SKILL.md +41 -0
- bq_inspector-0.1.0/.agents/skills/lint-and-fix/SKILL.md +72 -0
- bq_inspector-0.1.0/.agents/skills/manage-adr/SKILL.md +128 -0
- bq_inspector-0.1.0/.agents/skills/manage-adr/references/adr-concepts.md +21 -0
- bq_inspector-0.1.0/.agents/skills/manage-adr/references/adr-granularity.md +83 -0
- bq_inspector-0.1.0/.agents/skills/manage-adr/references/mermaid-diagrams.md +251 -0
- bq_inspector-0.1.0/.agents/skills/manage-adr/scripts/create-adr.sh +15 -0
- bq_inspector-0.1.0/.agents/skills/postmortem/SKILL.md +51 -0
- bq_inspector-0.1.0/.agents/skills/postmortem/references/postmortem-report-template.md +39 -0
- bq_inspector-0.1.0/.agents/skills/postmortem/references/solution-scorecard.md +61 -0
- bq_inspector-0.1.0/.agents/skills/problem-solving/README.md +18 -0
- bq_inspector-0.1.0/.agents/skills/problem-solving/SKILL.md +41 -0
- bq_inspector-0.1.0/.agents/skills/problem-solving/assets/templates/analysis-report.md +56 -0
- bq_inspector-0.1.0/.agents/skills/python-upgrade/SKILL.md +58 -0
- bq_inspector-0.1.0/.agents/skills/security-scan/SKILL.md +65 -0
- bq_inspector-0.1.0/.agents/skills/setup-dev-env/SKILL.md +20 -0
- bq_inspector-0.1.0/.agents/skills/test-and-fix/SKILL.md +42 -0
- bq_inspector-0.1.0/.bandit +4 -0
- bq_inspector-0.1.0/.claude/README.md +114 -0
- bq_inspector-0.1.0/.claude/agents/verifier.md +67 -0
- bq_inspector-0.1.0/.claude/commands/mend-adr.md +21 -0
- bq_inspector-0.1.0/.claude/hooks/block-dangerous.sh +35 -0
- bq_inspector-0.1.0/.claude/hooks/format-python.sh +18 -0
- bq_inspector-0.1.0/.claude/hooks/validate-commit.sh +25 -0
- bq_inspector-0.1.0/.claude/settings.json +107 -0
- bq_inspector-0.1.0/.codex/config.toml +15 -0
- bq_inspector-0.1.0/.cursor/sandbox.json +8 -0
- bq_inspector-0.1.0/.cursorignore +0 -0
- bq_inspector-0.1.0/.gemini/settings.json +5 -0
- bq_inspector-0.1.0/.gitignore +188 -0
- bq_inspector-0.1.0/.orchestrate/bq-inspector-python/plan.json +39 -0
- bq_inspector-0.1.0/.pylintrc +419 -0
- bq_inspector-0.1.0/AGENTS.md +173 -0
- bq_inspector-0.1.0/CHANGELOG.md +17 -0
- bq_inspector-0.1.0/CLAUDE.md +25 -0
- bq_inspector-0.1.0/CONTRIBUTING.md +188 -0
- bq_inspector-0.1.0/LICENSE +201 -0
- bq_inspector-0.1.0/Makefile +88 -0
- bq_inspector-0.1.0/PKG-INFO +520 -0
- bq_inspector-0.1.0/README.md +290 -0
- bq_inspector-0.1.0/docs/adr/0001-record-architecture-decisions.md +28 -0
- bq_inspector-0.1.0/docs/adr/0002-mise-toolchain-and-attestation-settings.md +46 -0
- bq_inspector-0.1.0/docs/adr/0003-python-port-from-typescript.md +55 -0
- bq_inspector-0.1.0/docs/adr/template.md +29 -0
- bq_inspector-0.1.0/mise.lock +140 -0
- bq_inspector-0.1.0/mise.toml +66 -0
- bq_inspector-0.1.0/pyproject.toml +117 -0
- bq_inspector-0.1.0/requirements.setup.txt +1 -0
- bq_inspector-0.1.0/ruff.toml +93 -0
- bq_inspector-0.1.0/src/bq_inspector/__init__.py +5 -0
- bq_inspector-0.1.0/src/bq_inspector/__main__.py +20 -0
- bq_inspector-0.1.0/src/bq_inspector/bigquery/adapters/__init__.py +1 -0
- bq_inspector-0.1.0/src/bq_inspector/bigquery/adapters/google_cloud/__init__.py +1 -0
- bq_inspector-0.1.0/src/bq_inspector/bigquery/adapters/google_cloud/sdk_inspection_client.py +162 -0
- bq_inspector-0.1.0/src/bq_inspector/bigquery/auth/create_auth_client.py +47 -0
- bq_inspector-0.1.0/src/bq_inspector/bigquery/errors/google_api_errors.py +184 -0
- bq_inspector-0.1.0/src/bq_inspector/bigquery/port/inspection_client.py +42 -0
- bq_inspector-0.1.0/src/bq_inspector/bigquery/types/list_jobs.py +23 -0
- bq_inspector-0.1.0/src/bq_inspector/bigquery/types/refs.py +14 -0
- bq_inspector-0.1.0/src/bq_inspector/cli/__init__.py +19 -0
- bq_inspector-0.1.0/src/bq_inspector/cli/argv/__init__.py +1 -0
- bq_inspector-0.1.0/src/bq_inspector/cli/click_cli.py +138 -0
- bq_inspector-0.1.0/src/bq_inspector/cli/click_decorators.py +65 -0
- bq_inspector-0.1.0/src/bq_inspector/cli/command_registry.py +201 -0
- bq_inspector-0.1.0/src/bq_inspector/cli/dispatch.py +61 -0
- bq_inspector-0.1.0/src/bq_inspector/cli/flat_jobs.py +36 -0
- bq_inspector-0.1.0/src/bq_inspector/cli/help.py +45 -0
- bq_inspector-0.1.0/src/bq_inspector/cli/jobs_subcommands.py +15 -0
- bq_inspector-0.1.0/src/bq_inspector/cli/params/__init__.py +1 -0
- bq_inspector-0.1.0/src/bq_inspector/cli/usage_build.py +158 -0
- bq_inspector-0.1.0/src/bq_inspector/commands/__init__.py +1 -0
- bq_inspector-0.1.0/src/bq_inspector/commands/command_shared.py +101 -0
- bq_inspector-0.1.0/src/bq_inspector/commands/datasets/__init__.py +1 -0
- bq_inspector-0.1.0/src/bq_inspector/commands/datasets/get.py +39 -0
- bq_inspector-0.1.0/src/bq_inspector/commands/jobs/__init__.py +1 -0
- bq_inspector-0.1.0/src/bq_inspector/commands/jobs/list.py +41 -0
- bq_inspector-0.1.0/src/bq_inspector/commands/jobs/run_jobs_view.py +79 -0
- bq_inspector-0.1.0/src/bq_inspector/commands/tables/__init__.py +1 -0
- bq_inspector-0.1.0/src/bq_inspector/commands/tables/get.py +48 -0
- bq_inspector-0.1.0/src/bq_inspector/commands/tables/list.py +39 -0
- bq_inspector-0.1.0/src/bq_inspector/core/datasets/get.py +50 -0
- bq_inspector-0.1.0/src/bq_inspector/core/jobs/bigquery_job_types.py +12 -0
- bq_inspector-0.1.0/src/bq_inspector/core/jobs/filter.py +139 -0
- bq_inspector-0.1.0/src/bq_inspector/core/jobs/get.py +191 -0
- bq_inspector-0.1.0/src/bq_inspector/core/jobs/list.py +79 -0
- bq_inspector-0.1.0/src/bq_inspector/core/jobs/list_request_fields.py +211 -0
- bq_inspector-0.1.0/src/bq_inspector/core/jobs/project_job.py +196 -0
- bq_inspector-0.1.0/src/bq_inspector/core/shared/api_error_hints.py +90 -0
- bq_inspector-0.1.0/src/bq_inspector/core/shared/catalog_error.py +56 -0
- bq_inspector-0.1.0/src/bq_inspector/core/shared/envelope.py +22 -0
- bq_inspector-0.1.0/src/bq_inspector/core/shared/errors.py +84 -0
- bq_inspector-0.1.0/src/bq_inspector/core/shared/iam_hints.py +17 -0
- bq_inspector-0.1.0/src/bq_inspector/core/shared/impersonation_fields.py +59 -0
- bq_inspector-0.1.0/src/bq_inspector/core/shared/job_ref.py +68 -0
- bq_inspector-0.1.0/src/bq_inspector/core/shared/normalize.py +19 -0
- bq_inspector-0.1.0/src/bq_inspector/core/shared/types.py +152 -0
- bq_inspector-0.1.0/src/bq_inspector/core/tables/get.py +52 -0
- bq_inspector-0.1.0/src/bq_inspector/core/tables/list.py +52 -0
- bq_inspector-0.1.0/src/bq_inspector/input/__init__.py +19 -0
- bq_inspector-0.1.0/src/bq_inspector/input/input_parsers.py +63 -0
- bq_inspector-0.1.0/src/bq_inspector/input/map_input.py +93 -0
- bq_inspector-0.1.0/src/bq_inspector/input/parsed_input_types.py +29 -0
- bq_inspector-0.1.0/src/bq_inspector/operational/__init__.py +27 -0
- bq_inspector-0.1.0/src/bq_inspector/operational/click_errors.py +23 -0
- bq_inspector-0.1.0/src/bq_inspector/operational/flags.py +32 -0
- bq_inspector-0.1.0/src/bq_inspector/operational/params.py +44 -0
- bq_inspector-0.1.0/src/bq_inspector/operational/parse_argv.py +63 -0
- bq_inspector-0.1.0/src/bq_inspector/operational/resolve.py +35 -0
- bq_inspector-0.1.0/src/bq_inspector/operational/types.py +21 -0
- bq_inspector-0.1.0/src/bq_inspector/py.typed +0 -0
- bq_inspector-0.1.0/src/bq_inspector/schemas/__init__.py +1 -0
- bq_inspector-0.1.0/src/bq_inspector/schemas/command_schemas.py +85 -0
- bq_inspector-0.1.0/src/bq_inspector/schemas/input_schema.py +200 -0
- bq_inspector-0.1.0/src/bq_inspector/schemas/output_schema.py +177 -0
- bq_inspector-0.1.0/src/bq_inspector/schemas/validate_input.py +74 -0
- bq_inspector-0.1.0/uv.lock +1421 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: build-and-fix
|
|
3
|
+
description: Build the project and automatically fix packaging or build errors (for example Hatch failures) and related breakage. Use when the project fails to build, shows "broken" states, or after making significant changes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build and Fix Loop
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
An autonomous loop for the agent to identify, analyze, and fix build errors using `make build`.
|
|
11
|
+
|
|
12
|
+
## Loop Logic
|
|
13
|
+
|
|
14
|
+
1. **Identify**: Run `make build` to identify build failures.
|
|
15
|
+
2. **Analyze**: Examine the build output to determine:
|
|
16
|
+
- The failing component (e.g., `hatch` build error).
|
|
17
|
+
- The specific error message (e.g., missing dependencies, syntax errors, packaging issues).
|
|
18
|
+
- For `make` / `uv` commands, see the project root [CLAUDE.md](../../../CLAUDE.md).
|
|
19
|
+
3. **Fix**: Apply the minimum necessary change to resolve the error (e.g., updating `pyproject.toml`, fixing syntax, or adding missing files).
|
|
20
|
+
4. **Verify**: Re-run `make build`.
|
|
21
|
+
- If passed: Finish.
|
|
22
|
+
- If failed: Analyze the new failure and repeat the loop.
|
|
23
|
+
|
|
24
|
+
## Termination Criteria
|
|
25
|
+
|
|
26
|
+
- The project builds successfully (as reported by `make build`).
|
|
27
|
+
- Reached max iteration limit (default: 5).
|
|
28
|
+
- The error persists after multiple distinct fix attempts, indicating a need for human intervention.
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
### Scenario: Fixing a packaging error
|
|
33
|
+
|
|
34
|
+
1. `make build` fails because of a missing dependency in `pyproject.toml`.
|
|
35
|
+
2. Agent analyzes the error, adds the dependency using `uv add`.
|
|
36
|
+
3. `make build` now passes.
|
|
37
|
+
|
|
38
|
+
## Resources
|
|
39
|
+
|
|
40
|
+
- [Hatch Documentation](https://hatch.pypa.io/): Official documentation for the Hatch build backend.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: check-directory-structure
|
|
3
|
+
description: Inspect repository layout with tree and find, compare to AGENTS.md conventions, and fix misplaced or overly flat generated files. Use when auditing folder structure, after scaffolding or bulk file generation, when output looks flat, or when asked where code/tests/docs should live. Supports inspecting the repository root or a specified subdirectory.
|
|
4
|
+
compatibility: Unix-like shell. POSIX find required; optional tree for readability (install via OS package manager if missing). Run from inside the working tree; set TARGET to the directory to inspect (default `.` for the current directory, often the repo root after `cd`).
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Check directory structure
|
|
8
|
+
|
|
9
|
+
## Purpose
|
|
10
|
+
|
|
11
|
+
Ground work in the **actual** on-disk layout and catch **flat or misplaced** output (for example many new files at the repository root) before finishing a task.
|
|
12
|
+
|
|
13
|
+
## When to use
|
|
14
|
+
|
|
15
|
+
- After scaffolding, renaming the package, or generating several new files
|
|
16
|
+
- When imports or paths feel wrong compared to where files really live
|
|
17
|
+
- When the user asks where code, tests, or scripts should live
|
|
18
|
+
- When output looks like a **flat dump** instead of nested package layout
|
|
19
|
+
|
|
20
|
+
## How to run
|
|
21
|
+
|
|
22
|
+
Read **Architecture** and testing layout in [`AGENTS.md`](../../../AGENTS.md). Resolve the real package name from `pyproject.toml` / `src/` on disk (the template uses `your_package` until [`initialize-project`](../../../.claude/skills/initialize-project/SKILL.md) runs).
|
|
23
|
+
|
|
24
|
+
**Target directory:** By default, inspect the **current directory** (after `cd` to the repository root, that is the whole repo). To inspect only a subtree—for example a package or feature folder—set `TARGET` to that path (repo-relative or absolute). Examples: `TARGET=.` (same as root after `cd` to repo root), `TARGET=src/your_package`, `TARGET=dev`. Use the same `TARGET` in every command below.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# From repository root; inspect whole repo
|
|
28
|
+
TARGET=.
|
|
29
|
+
|
|
30
|
+
# Or inspect only a subtree (repo-relative or absolute path)
|
|
31
|
+
TARGET=src/your_package
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 1. Snapshot layout
|
|
35
|
+
|
|
36
|
+
**Optional — readable tree** (skip if `tree` is not installed):
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
tree -L 3 -a -I '.git|__pycache__|.venv|node_modules|dist|build|.pytest_cache|.ruff_cache' "${TARGET:-.}"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**POSIX `find` — works without `tree`:** run from inside `TARGET` so skipping `.git`, `.venv`, and `__pycache__` works for both the repo root and a subdirectory.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Immediate children of TARGET (plus `.` for the root of the scanned tree)
|
|
46
|
+
(cd "${TARGET:-.}" && find . \( -name '.git' -o -name '.venv' -o -name '__pycache__' \) -prune -o -maxdepth 1 -print)
|
|
47
|
+
|
|
48
|
+
# Sample of files under TARGET (cap output on large trees)
|
|
49
|
+
(cd "${TARGET:-.}" && find . \( -name '.git' -o -name '.venv' \) -prune -o \( -type d -name '__pycache__' \) -prune -o -type f -print | head -200)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Optional — depth signal** (rough hint for flat vs nested paths under `TARGET`):
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
(cd "${TARGET:-.}" && find . -type f -print | awk -F/ '{ print NF-1 }' | sort -n | tail -5)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
If `TARGET` is not the repository root, map what you see back to the **full** repo layout in [`AGENTS.md`](../../../AGENTS.md) (for example `src/<package>/` vs `dev/`).
|
|
59
|
+
|
|
60
|
+
### 2. Compare to this repository
|
|
61
|
+
|
|
62
|
+
- **Package code** lives under `src/<package>/`, not loose Python modules at the repository root.
|
|
63
|
+
- **Tests** live under `src/<package>/tests/`; files match `test_*.py` (see [`AGENTS.md`](../../../AGENTS.md)).
|
|
64
|
+
- **Dev scripts:** `dev/`; **CI:** `.github/workflows/`; **ADRs:** `docs/adr/` when used.
|
|
65
|
+
|
|
66
|
+
If the tree still shows `your_package` but the project should use a real name, follow [`initialize-project`](../../../.claude/skills/initialize-project/SKILL.md).
|
|
67
|
+
|
|
68
|
+
### 3. Fix loop
|
|
69
|
+
|
|
70
|
+
1. **Move** misplaced files to match the conventions above.
|
|
71
|
+
2. **Update** imports, packaging paths in `pyproject.toml`, and references in docs or CI if paths changed.
|
|
72
|
+
3. **Verify** with `make lint && make test` per [`AGENTS.md`](../../../AGENTS.md).
|
|
73
|
+
|
|
74
|
+
## Termination
|
|
75
|
+
|
|
76
|
+
- Layout matches documented conventions, or
|
|
77
|
+
- Remaining differences are **explicitly accepted** with a short rationale, or
|
|
78
|
+
- After **2** relocate/fix iterations, stop and list remaining items for the user.
|
|
79
|
+
|
|
80
|
+
## Related
|
|
81
|
+
|
|
82
|
+
- [`AGENTS.md`](../../../AGENTS.md) — Architecture, testing, quick commands
|
|
83
|
+
- [`CLAUDE.md`](../../../CLAUDE.md) — Claude Code entrypoint and `.claude/` layout
|
|
84
|
+
- [`initialize-project`](../../../.claude/skills/initialize-project/SKILL.md) — Rename template package and bootstrap
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codeql-fix
|
|
3
|
+
description: Run CodeQL security/quality analysis and fix findings. Use when the user asks to run CodeQL, security scan, static analysis, or fix CodeQL findings.
|
|
4
|
+
compatibility: Requires [CodeQL CLI](https://github.com/github/codeql-cli-binaries/releases) on PATH via `make setup-tools` or mise (`mise.toml`). Python and [uv](https://github.com/astral-sh/uv) aligned with [`.python-version`](../../../.python-version) and [`pyproject.toml`](../../../pyproject.toml). Run `uv sync` or `make setup` before analysis when findings should reflect installed dependencies (matches [`.github/workflows/codeql.yml`](../../../.github/workflows/codeql.yml)).
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# CodeQL Fix
|
|
8
|
+
|
|
9
|
+
Use when the user asks to run CodeQL or static analysis, or to fix CodeQL findings (see frontmatter `description`).
|
|
10
|
+
|
|
11
|
+
## Preconditions
|
|
12
|
+
|
|
13
|
+
- [CodeQL CLI](https://github.com/github/codeql-cli-binaries/releases) on `PATH` via **`make setup-tools`**, **`make codeql`** (`mise run codeql`), or **`mise install --locked`** per `mise.toml`.
|
|
14
|
+
- Install project deps before creating the database (`uv sync`, `make setup`, or CI-style `uv sync --frozen`) so results match installed dependencies.
|
|
15
|
+
|
|
16
|
+
## Run analysis (repository root)
|
|
17
|
+
|
|
18
|
+
All commands below assume `cd "$(git rev-parse --show-toplevel)"`.
|
|
19
|
+
|
|
20
|
+
Do not commit CodeQL databases or SARIF outputs (large, machine-specific). They belong in [`.gitignore`](../../../.gitignore) (for example `.codeql_db/`, `codeql-results.sarif`).
|
|
21
|
+
|
|
22
|
+
### 1. Preferred: Makefile (matches [`dev/codeql.sh`](../../../dev/codeql.sh))
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
make codeql
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This creates **`.codeql_db`**, analyzes with **`codeql/python-queries:codeql-suites/python-security-and-quality.qls`**, writes **`codeql-results.sarif`**, and passes **`--download`** to resolve query packs.
|
|
29
|
+
|
|
30
|
+
### 2. Manual CLI (equivalent to the script)
|
|
31
|
+
|
|
32
|
+
Create the database (Python needs no build command for extraction):
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
codeql database create .codeql_db --language=python --source-root . --overwrite
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Analyze and emit SARIF:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
codeql database analyze .codeql_db \
|
|
42
|
+
"codeql/python-queries:codeql-suites/python-security-and-quality.qls" \
|
|
43
|
+
--format=sarif-latest \
|
|
44
|
+
--output=codeql-results.sarif \
|
|
45
|
+
--download
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- For a narrower suite closer to default GitHub code scanning, use `codeql/python-queries:codeql-suites/python-code-scanning.qls` instead.
|
|
49
|
+
- If packs are missing and you are not using `--download`, run `codeql pack download codeql/python-queries` once.
|
|
50
|
+
|
|
51
|
+
View SARIF in the VS Code SARIF extension (or upload where your org uses code scanning).
|
|
52
|
+
|
|
53
|
+
### 3. Optional: code scanning config (`paths-ignore`)
|
|
54
|
+
|
|
55
|
+
Use the renderer when you want `paths-ignore` for large or generated trees, hand-edited query blocks, or parity with GitHub code scanning YAML.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
REPO="$(git rev-parse --show-toplevel)"
|
|
59
|
+
"$REPO/.claude/skills/codeql-fix/scripts/render-code-scanning-config.sh" "$REPO" /tmp/codeql-config.yml
|
|
60
|
+
codeql database create .codeql_db --language=python --source-root . --codescanning-config=/tmp/codeql-config.yml --overwrite
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Then run `codeql database analyze` as in section 2. See [references/code-scanning-config.md](references/code-scanning-config.md).
|
|
64
|
+
|
|
65
|
+
## Fixer loop
|
|
66
|
+
|
|
67
|
+
If the relevant SARIF has an empty `runs[].results` array, there are **no CodeQL alerts to fix** for that suite; stop unless the user wants a broader suite or diagnostic queries.
|
|
68
|
+
|
|
69
|
+
When SARIF findings remain:
|
|
70
|
+
|
|
71
|
+
1. **Identify:** Read the SARIF or CLI output for reported findings.
|
|
72
|
+
2. **Fix:** Apply the minimum necessary edit to resolve each finding.
|
|
73
|
+
3. **Verify:** From the repository root, run `make test`, then `make lint` (see [AGENTS.md](../../../AGENTS.md) and the [Makefile](../../../Makefile); `make lint` runs `trunk check -a`).
|
|
74
|
+
4. **Re-scan:** Run `make codeql` or repeat the manual create + analyze steps until clean or up to 3 iterations to avoid unbounded loops.
|
|
75
|
+
|
|
76
|
+
## Optional: code scanning config details
|
|
77
|
+
|
|
78
|
+
See [references/code-scanning-config.md](references/code-scanning-config.md) and the official [code scanning configuration](https://aka.ms/code-scanning-docs/config-file) reference.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Code scanning configuration (template — do not pass this file directly to codeql).
|
|
2
|
+
# Render a repo-specific file with: scripts/render-code-scanning-config.sh
|
|
3
|
+
#
|
|
4
|
+
# Skill reference: ../references/code-scanning-config.md (from this template file)
|
|
5
|
+
# Official schema and fields: https://aka.ms/code-scanning-docs/config-file
|
|
6
|
+
#
|
|
7
|
+
# The renderer replaces the "name:" line and appends "paths-ignore" when needed.
|
|
8
|
+
# After rendering, you may hand-edit the output (e.g. query suites) before
|
|
9
|
+
# codeql database create --codescanning-config=<file>
|
|
10
|
+
#
|
|
11
|
+
# Optional: enable a query suite in the generated file (examples — uncomment in output):
|
|
12
|
+
# queries:
|
|
13
|
+
# - uses: security-extended
|
|
14
|
+
# - uses: security-and-quality
|
|
15
|
+
#
|
|
16
|
+
# Placeholder name — replaced by render-code-scanning-config.sh (or override via CODEQL_CONFIG_NAME)
|
|
17
|
+
name: local-codeql
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Code scanning config (template + renderer)
|
|
2
|
+
|
|
3
|
+
This skill ships a YAML template and a small shell renderer under the same directory as [`SKILL.md`](../SKILL.md).
|
|
4
|
+
|
|
5
|
+
- **Template:** [`assets/code-scanning-config.template.yml`](../assets/code-scanning-config.template.yml)
|
|
6
|
+
- **Renderer:** [`scripts/render-code-scanning-config.sh`](../scripts/render-code-scanning-config.sh)
|
|
7
|
+
|
|
8
|
+
Local CodeQL in this repository is **CLI-driven** for **Python**: primary extraction uses `codeql database create` with `--language=python` and `--source-root .` (no build command). See [`SKILL.md`](../SKILL.md) and [`dev/codeql.sh`](../../../../dev/codeql.sh) for the full `database create` / `database analyze` flow.
|
|
9
|
+
|
|
10
|
+
When `CODEQL_CONFIG_REPO_SCAN` is enabled (default), the renderer adds common noise paths if present (for example `.git`, `node_modules`, `.codeql_db`, virtualenvs, Python caches, coverage output). It intentionally stays minimal for this template; use comma-separated **`CODEQL_PATHS_IGNORE`** (and optional extra CLI arguments to the script) for monorepo build dirs, e2e artifacts, Terraform caches, or other repo-specific trees.
|
|
11
|
+
|
|
12
|
+
Pass the rendered file to `codeql database create --codescanning-config=<file>` when you need `paths-ignore` or other [code scanning configuration](https://aka.ms/code-scanning-docs/config-file) options beyond a bare `--source-root .` create.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Render Code Scanning YAML from assets/code-scanning-config.template.yml for a repository.
|
|
3
|
+
# Merges CODEQL_PATHS_IGNORE, extra CLI paths, and optional existence-based paths-ignore
|
|
4
|
+
# tuned for this Python template. Add monorepo/e2e paths via CODEQL_PATHS_IGNORE or by
|
|
5
|
+
# extending the scan block below.
|
|
6
|
+
# Docs: https://aka.ms/code-scanning-docs/config-file
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
usage() {
|
|
10
|
+
echo "Usage: $0 <repo-root> <output-yaml> [extra-path-to-ignore ...]" >&2
|
|
11
|
+
echo "Env: CODEQL_CONFIG_NAME (override name), CODEQL_PATHS_IGNORE (comma-separated)," >&2
|
|
12
|
+
echo " CODEQL_CONFIG_REPO_SCAN=0|false to skip auto paths-ignore from repo layout" >&2
|
|
13
|
+
exit 2
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
[[ $# -ge 2 ]] || usage
|
|
17
|
+
REPO=$(cd "$1" && pwd)
|
|
18
|
+
OUT="$2"
|
|
19
|
+
shift 2
|
|
20
|
+
|
|
21
|
+
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
22
|
+
SKILL_ROOT=$(cd "${SCRIPT_DIR}/.." && pwd)
|
|
23
|
+
TEMPLATE="${SKILL_ROOT}/assets/code-scanning-config.template.yml"
|
|
24
|
+
|
|
25
|
+
if [[ ! -f ${TEMPLATE} ]]; then
|
|
26
|
+
echo "Missing template: ${TEMPLATE}" >&2
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
CONFIG_NAME=${CODEQL_CONFIG_NAME-}
|
|
31
|
+
if [[ -z ${CONFIG_NAME} ]]; then
|
|
32
|
+
if top=$(git -C "${REPO}" rev-parse --show-toplevel 2>/dev/null); then
|
|
33
|
+
CONFIG_NAME=$(basename "${top}")
|
|
34
|
+
else
|
|
35
|
+
CONFIG_NAME=local-codeql
|
|
36
|
+
fi
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
paths_tmp=$(mktemp)
|
|
40
|
+
tmp_out=$(mktemp)
|
|
41
|
+
cleanup() {
|
|
42
|
+
rm -f "${paths_tmp}" "${tmp_out}"
|
|
43
|
+
}
|
|
44
|
+
trap cleanup EXIT
|
|
45
|
+
|
|
46
|
+
add_path() {
|
|
47
|
+
local p="${1//[$'\t\r\n']/}"
|
|
48
|
+
# Trim leading/trailing whitespace without spawning sed.
|
|
49
|
+
p="${p#"${p%%[![:space:]]*}"}"
|
|
50
|
+
p="${p%"${p##*[![:space:]]}"}"
|
|
51
|
+
[[ -z ${p} ]] && return
|
|
52
|
+
if [[ -s ${paths_tmp} ]] && grep -Fxq "${p}" "${paths_tmp}" 2>/dev/null; then
|
|
53
|
+
return
|
|
54
|
+
fi
|
|
55
|
+
echo "${p}" >>"${paths_tmp}"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if [[ -n ${CODEQL_PATHS_IGNORE-} ]]; then
|
|
59
|
+
IFS=',' read -r -a _parts <<<"${CODEQL_PATHS_IGNORE}"
|
|
60
|
+
for p in "${_parts[@]}"; do
|
|
61
|
+
add_path "${p}"
|
|
62
|
+
done
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
for p in "$@"; do
|
|
66
|
+
add_path "${p}"
|
|
67
|
+
done
|
|
68
|
+
|
|
69
|
+
_scan=${CODEQL_CONFIG_REPO_SCAN:-1}
|
|
70
|
+
if [[ ${_scan} == "1" || ${_scan} == "true" ]]; then
|
|
71
|
+
[[ -d "${REPO}/node_modules" ]] && add_path "node_modules"
|
|
72
|
+
[[ -d "${REPO}/.git" ]] && add_path ".git"
|
|
73
|
+
[[ -d "${REPO}/dist" ]] && add_path "**/dist"
|
|
74
|
+
[[ -d "${REPO}/coverage" ]] && add_path "coverage"
|
|
75
|
+
[[ -d "${REPO}/htmlcov" ]] && add_path "htmlcov"
|
|
76
|
+
[[ -d "${REPO}/.pytest_cache" ]] && add_path ".pytest_cache"
|
|
77
|
+
[[ -d "${REPO}/.ruff_cache" ]] && add_path ".ruff_cache"
|
|
78
|
+
[[ -d "${REPO}/codeql-db" ]] && add_path "codeql-db"
|
|
79
|
+
[[ -d "${REPO}/.codeql_db" ]] && add_path ".codeql_db"
|
|
80
|
+
add_path "**/.venv"
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
if [[ -s ${paths_tmp} ]]; then
|
|
84
|
+
sort -u "${paths_tmp}" -o "${paths_tmp}"
|
|
85
|
+
fi
|
|
86
|
+
path_count=0
|
|
87
|
+
if [[ -s ${paths_tmp} ]]; then
|
|
88
|
+
path_count=$(wc -l <"${paths_tmp}")
|
|
89
|
+
path_count=${path_count// /}
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
{
|
|
93
|
+
while IFS= read -r line || [[ -n ${line-} ]]; do
|
|
94
|
+
if [[ ${line} =~ ^name:[[:space:]] ]]; then
|
|
95
|
+
echo "name: ${CONFIG_NAME}"
|
|
96
|
+
else
|
|
97
|
+
printf '%s\n' "${line}"
|
|
98
|
+
fi
|
|
99
|
+
done <"${TEMPLATE}"
|
|
100
|
+
|
|
101
|
+
if [[ ${path_count} -gt 0 ]]; then
|
|
102
|
+
echo "paths-ignore:"
|
|
103
|
+
while IFS= read -r p || [[ -n ${p-} ]]; do
|
|
104
|
+
[[ -z ${p-} ]] && continue
|
|
105
|
+
# Quote values so YAML does not treat '*' (e.g. **/.venv) as alias syntax.
|
|
106
|
+
_esc=${p//\\/\\\\}
|
|
107
|
+
_esc=${_esc//\"/\\\"}
|
|
108
|
+
printf ' - "%s"\n' "${_esc}"
|
|
109
|
+
done <"${paths_tmp}"
|
|
110
|
+
fi
|
|
111
|
+
} >"${tmp_out}"
|
|
112
|
+
|
|
113
|
+
mv "${tmp_out}" "${OUT}"
|
|
114
|
+
trap - EXIT
|
|
115
|
+
rm -f "${paths_tmp}"
|
|
116
|
+
echo "Wrote ${OUT}" >&2
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Deep Problem Solving
|
|
2
|
+
|
|
3
|
+
Companion README for [`SKILL.md`](SKILL.md). Interactive decision support: deep framing, then **exactly ten** multiple-choice questions (one per turn), then a scored comparison and recommendation. Output uses [`references/full-report-template.md`](references/full-report-template.md).
|
|
4
|
+
|
|
5
|
+
## Triggers (examples)
|
|
6
|
+
|
|
7
|
+
- “Don’t jump to a solution—ask me questions first, then compare options with scores.”
|
|
8
|
+
- High-stakes architecture or strategy where priorities need to be elicited before scoring.
|
|
9
|
+
|
|
10
|
+
## Layout
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
deep-problem-solving/
|
|
14
|
+
├── SKILL.md
|
|
15
|
+
├── README.md
|
|
16
|
+
└── references/full-report-template.md
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This repository may ship other skills under [`.claude/skills/`](..); pick the skill whose frontmatter **description** matches your task. Routing for decision-support variants is summarized in [AGENTS.md](../../../AGENTS.md) (Claude Code skills table).
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deep-problem-solving
|
|
3
|
+
description: |
|
|
4
|
+
Interactive deep research and decision support: frame the real problem (XY-aware), ask exactly 10 multiple-choice questions one at a time, then produce a rigorous comparative evaluation (default 5 approaches, 0–100 scores) and recommendation.
|
|
5
|
+
Use when the user wants structured discovery before committing to a solution, a scored comparison of approaches, or to avoid jumping straight to an answer—especially for architecture, strategy, or high-stakes trade-offs.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Deep Problem Solving (Interactive Deep-Research Solution Evaluator)
|
|
9
|
+
|
|
10
|
+
## Relationship to single-pass analysis
|
|
11
|
+
|
|
12
|
+
Another mode in this repo is a **single-pass** XY-aware analysis and scored comparison (no mandatory question phase). **This skill adds Phase 1 framing, then exactly ten interactive questions (one per user turn), then Phase 3 evaluation.** Do not skip Phase 2. Do not emit the final report until Phase 2 is complete unless the user explicitly stops early.
|
|
13
|
+
|
|
14
|
+
## Role
|
|
15
|
+
|
|
16
|
+
You are an expert research and decision-support assistant. Help the user identify the real problem, explore the solution space interactively, then produce a rigorous comparative recommendation. **Do not jump straight to solutions.**
|
|
17
|
+
|
|
18
|
+
## Required workflow
|
|
19
|
+
|
|
20
|
+
Follow this sequence exactly.
|
|
21
|
+
|
|
22
|
+
### Phase 1 — Deep research and problem framing
|
|
23
|
+
|
|
24
|
+
Before proposing any solution, analyze the situation broadly and deeply. **Do not generate final recommendations in this phase.**
|
|
25
|
+
|
|
26
|
+
Your analysis must include:
|
|
27
|
+
|
|
28
|
+
1. **Stated Problem (X)** — What the user explicitly asked for.
|
|
29
|
+
2. **Underlying Intent (Y)** — The deeper goal they are actually trying to achieve.
|
|
30
|
+
3. **XY problem check** — Test whether X is only an intermediate step, an assumed constraint, or a potentially suboptimal path to Y. If so, say so clearly and explain why.
|
|
31
|
+
4. **Context expansion** — Surrounding constraints, assumptions, dependencies, risks, stakeholders, trade-offs, and failure modes.
|
|
32
|
+
5. **Research depth** — Consider multiple angles where relevant (technical, operational, strategic, UX, maintainability, performance, security, cost, scalability, compliance, time-to-deliver).
|
|
33
|
+
|
|
34
|
+
### Phase 2 — Ten interactive questions, one per turn
|
|
35
|
+
|
|
36
|
+
After Phase 1, ask **exactly 10 questions**, **one per turn**, to refine direction before the final evaluation.
|
|
37
|
+
|
|
38
|
+
Rules:
|
|
39
|
+
|
|
40
|
+
1. Ask **only one question per turn**.
|
|
41
|
+
2. Each question must include **multiple answer options** (prefer **3 to 6**).
|
|
42
|
+
3. Include **Other / Explain** when helpful.
|
|
43
|
+
4. Each question should narrow priorities, constraints, preferences, risk tolerance, timeline, budget, quality bar, architecture direction, success criteria, or acceptable trade-offs.
|
|
44
|
+
5. **Adapt** later questions based on earlier answers.
|
|
45
|
+
6. Do not skip ahead. Do not provide the final report until all 10 questions are answered, unless the user explicitly asks to stop early.
|
|
46
|
+
7. Keep questions concise; make options concrete and decision-useful.
|
|
47
|
+
8. After each answer, **briefly acknowledge** it, then ask the next question.
|
|
48
|
+
|
|
49
|
+
**Question format** (use every time):
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
**Question {N}/10: [short title]**
|
|
53
|
+
[One concise sentence explaining what is being decided.]
|
|
54
|
+
|
|
55
|
+
A. [Option A]
|
|
56
|
+
B. [Option B]
|
|
57
|
+
C. [Option C]
|
|
58
|
+
D. [Option D]
|
|
59
|
+
E. [Optional: Other / Explain]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Platform:** If the environment offers a multiple-choice or structured question UI, use it with the same options. Otherwise use plain text as above.
|
|
63
|
+
|
|
64
|
+
### Phase 3 — Full structured evaluation
|
|
65
|
+
|
|
66
|
+
After Question 10 is answered (or the user stopped early), proceed:
|
|
67
|
+
|
|
68
|
+
1. **Analyze intent and issue** — Stated X, underlying Y, XY check, context and impact (root causes, system implications, trade-offs, downstream effects).
|
|
69
|
+
2. **Determine approaches** — Generate **n** distinct approaches that satisfy **Y**, default **n = 5** (or the user’s number). Include approaches that solve Y directly even if they bypass X.
|
|
70
|
+
3. **Define scoring criteria** — Tailor to the problem and to Phase 2 answers (e.g. feasibility, complexity, speed, cost, performance, maintainability, security, scalability, reliability, compliance, user impact, reversibility, operational burden). Use only relevant criteria.
|
|
71
|
+
4. **Score approaches** — For each criterion, score each approach **0–100**. Be explicit and consistent; justify non-obvious scores; avoid inflation; reflect Phase 2 priorities; state high uncertainty when needed.
|
|
72
|
+
5. **Recommend** — Choose the best approach using intent alignment, score profile, critical trade-offs, constraints, and long-term consequences. Also cover: when the top-scoring option may **not** be best in practice; assumptions that could change the recommendation; a strong second choice under different constraints.
|
|
73
|
+
|
|
74
|
+
## Final report
|
|
75
|
+
|
|
76
|
+
After Phase 2 is complete, generate the report using the structure in [references/full-report-template.md](references/full-report-template.md).
|
|
77
|
+
|
|
78
|
+
## Behavioral rules
|
|
79
|
+
|
|
80
|
+
- Do not rush. Do not assume the user’s first framing is correct.
|
|
81
|
+
- Do not skip the 10-question phase (unless the user explicitly ends it early).
|
|
82
|
+
- Do not ask all 10 questions in one message.
|
|
83
|
+
- Do not deliver the final recommendation report before the questioning phase is finished, unless the user explicitly requests an early stop.
|
|
84
|
+
- Challenge flawed premises when evidence supports it. Optimize for the user’s real objective, not only their first requested method.
|
|
85
|
+
- Prefer clarity, rigor, and practical usefulness over superficial completeness.
|
|
86
|
+
|
|
87
|
+
## Start condition
|
|
88
|
+
|
|
89
|
+
When this skill is activated:
|
|
90
|
+
|
|
91
|
+
1. Perform the Phase 1 framing analysis **internally** (you may show a concise version to the user as part of the opening).
|
|
92
|
+
2. Briefly summarize **Stated Problem (X)**, **Underlying Intent (Y)**, and **possible XY risk**.
|
|
93
|
+
3. Immediately ask **Question 1/10** with answer options.
|
|
94
|
+
4. **Do not** generate the full final report yet.
|
|
95
|
+
|
|
96
|
+
## Examples
|
|
97
|
+
|
|
98
|
+
**User:** “We need to move off our self-hosted Redis.”
|
|
99
|
+
|
|
100
|
+
**Agent:** Short summary of X (migrate Redis) vs Y (reliability, ops cost, etc.) and XY note if applicable → **Question 1/10** with options (e.g. managed Redis vs memory store vs redesign cache layer, etc.).
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<!-- Report template for interactive discovery (ten-question phase before scoring). -->
|
|
2
|
+
|
|
3
|
+
# Intent & Issue Analysis Report
|
|
4
|
+
|
|
5
|
+
## 1. Intent & Issue Analysis
|
|
6
|
+
|
|
7
|
+
### Stated Problem (X)
|
|
8
|
+
|
|
9
|
+
<!-- What the user explicitly asked for. -->
|
|
10
|
+
|
|
11
|
+
### Underlying Intent (Y)
|
|
12
|
+
|
|
13
|
+
<!-- The deeper goal the user is likely trying to achieve. -->
|
|
14
|
+
|
|
15
|
+
### XY Problem Check
|
|
16
|
+
|
|
17
|
+
<!-- Explicit analysis of whether X is distracting from or inferior to solving Y directly. -->
|
|
18
|
+
|
|
19
|
+
### Context & Impact
|
|
20
|
+
|
|
21
|
+
<!-- Deep analysis of context, assumptions, constraints, root causes, and likely impacts. -->
|
|
22
|
+
|
|
23
|
+
## 2. Evaluation Criteria
|
|
24
|
+
|
|
25
|
+
<!-- List and define the criteria used for scoring, tailored to the user's situation and Phase 2 answers. -->
|
|
26
|
+
|
|
27
|
+
## 3. Approaches
|
|
28
|
+
|
|
29
|
+
<!-- Default: n = 5. Adjust headings if the user requested a different n. -->
|
|
30
|
+
|
|
31
|
+
### Approach 1: [Name]
|
|
32
|
+
|
|
33
|
+
- **Description**:
|
|
34
|
+
- **Pros**:
|
|
35
|
+
- **Cons**:
|
|
36
|
+
|
|
37
|
+
### Approach 2: [Name]
|
|
38
|
+
|
|
39
|
+
- **Description**:
|
|
40
|
+
- **Pros**:
|
|
41
|
+
- **Cons**:
|
|
42
|
+
|
|
43
|
+
### Approach 3: [Name]
|
|
44
|
+
|
|
45
|
+
- **Description**:
|
|
46
|
+
- **Pros**:
|
|
47
|
+
- **Cons**:
|
|
48
|
+
|
|
49
|
+
### Approach 4: [Name]
|
|
50
|
+
|
|
51
|
+
- **Description**:
|
|
52
|
+
- **Pros**:
|
|
53
|
+
- **Cons**:
|
|
54
|
+
|
|
55
|
+
### Approach 5: [Name]
|
|
56
|
+
|
|
57
|
+
- **Description**:
|
|
58
|
+
- **Pros**:
|
|
59
|
+
- **Cons**:
|
|
60
|
+
|
|
61
|
+
## 4. Scoring Matrix
|
|
62
|
+
|
|
63
|
+
| Approach | [Criterion 1] | [Criterion 2] | [Criterion 3] | [Criterion 4] | Average |
|
|
64
|
+
| :--------- | :-----------: | :-----------: | :-----------: | :-----------: | :-----: |
|
|
65
|
+
| Approach 1 | | | | | |
|
|
66
|
+
| Approach 2 | | | | | |
|
|
67
|
+
| Approach 3 | | | | | |
|
|
68
|
+
| Approach 4 | | | | | |
|
|
69
|
+
| Approach 5 | | | | | |
|
|
70
|
+
|
|
71
|
+
_Scores are from 0 to 100._
|
|
72
|
+
|
|
73
|
+
## 5. Recommendation
|
|
74
|
+
|
|
75
|
+
<!-- Final recommendation, reasoning, trade-offs, caveats, when top score may not be best, assumptions that could change the pick, and second-best under different constraints. -->
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: initialize-project
|
|
3
|
+
description: Initialize a new project from the Python template by renaming packages, updating metadata, and cleaning up documentation. Use when starting a new project, "bootstrapping" from this template, or setting up a fresh repository.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Initialize Project
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
This skill automates the initial setup of a new project derived from this template. It leverages AI capabilities to directly modify project metadata and documentation by replacing placeholders, ensuring a clean start for a new repository.
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
1. **Gather Information**: Ask the user for:
|
|
15
|
+
- New project name (e.g., `my-awesome-app`)
|
|
16
|
+
- Project description
|
|
17
|
+
- Author name (e.g., `Your Name <your.email@example.com>`)
|
|
18
|
+
2. **Update Project Metadata**: Directly update the following files using the `Write` or `StrReplace` tools:
|
|
19
|
+
- `pyproject.toml`: Update `project.name`, `project.description`, and `project.authors`.
|
|
20
|
+
- Update `tool.hatch.build.targets.wheel.packages` to match the new source directory.
|
|
21
|
+
3. **Rename Source Package**:
|
|
22
|
+
- Rename `src/your_package` to the new package name (e.g., `src/my_awesome_app`).
|
|
23
|
+
- Update any internal imports if they reference `your_package`.
|
|
24
|
+
4. **Update README Placeholders**: Use the `StrReplace` tool to replace the placeholders in `README.md` with the gathered information:
|
|
25
|
+
- `{PROJECT_NAME}` -> New project name
|
|
26
|
+
- `{PROJECT_DESCRIPTION}` -> Project description
|
|
27
|
+
5. **Install Dependencies**: Run `make setup` to initialize the environment and update `uv.lock`.
|
|
28
|
+
6. **Final Cleanup**: Remove the initialization skill and its related files once bootstrapping is complete, if requested by the user.
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
### Example 1: Initializing a new CLI tool
|
|
33
|
+
|
|
34
|
+
**Input**: User says "Initialize this project as 'json-fixer', a CLI tool to fix broken JSON files."
|
|
35
|
+
**Action**:
|
|
36
|
+
|
|
37
|
+
1. Gather details from the user (Name: json-fixer, Description: A CLI tool to fix broken JSON files, Author: [Author Name]).
|
|
38
|
+
2. Update `pyproject.toml` with the new metadata.
|
|
39
|
+
3. Rename `src/your_package` to `src/json_fixer`.
|
|
40
|
+
4. Use `StrReplace` on `README.md` to swap placeholders with actual values.
|
|
41
|
+
5. Run `make setup`.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lint-and-fix
|
|
3
|
+
description: Run linters and fix violations, formatting errors, or style mismatches using Trunk. Use when code quality checks fail, before submitting PRs, or to repair "broken" linting states.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Lint and Fix Loop: Trunk
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
An autonomous loop for the agent to identify, fix, and verify linting and formatting violations using [Trunk](https://trunk.io), plus dead-code detection with [Vulture](https://github.com/jendrikseipp/vulture).
|
|
11
|
+
|
|
12
|
+
## Trunk CLI resolution
|
|
13
|
+
|
|
14
|
+
`make lint` and `make format` delegate to **`mise run lint`** and **`mise run format-trunk`** (see `mise.toml`). Resolve Trunk **once** at the start of the loop:
|
|
15
|
+
|
|
16
|
+
1. After **`make setup-tools`** (or `mise install --locked`), prefer **`make lint`** / **`make format`** so mise activates the pinned `trunk` from `mise.lock`.
|
|
17
|
+
2. If `trunk` is on `PATH` (`command -v trunk`), you may also call `trunk check -a` / `trunk fmt -a` directly (same as `mise run lint` / `mise run format-trunk` when shims are active).
|
|
18
|
+
3. Otherwise use the NPM launcher: **`npx --yes @trunkio/launcher`** with the same subcommands (for example `npx --yes @trunkio/launcher check -a`, `npx --yes @trunkio/launcher fmt -a`, `npx --yes @trunkio/launcher install`).
|
|
19
|
+
4. If Trunk reports missing managed tools, run **`mise run trunk-install`** or **`make setup-tools`** (or the `npx … install` form above) per [AGENTS.md](../../../AGENTS.md).
|
|
20
|
+
|
|
21
|
+
When `trunk` is missing from `PATH` and mise is not installed, prefer explicit **`npx --yes @trunkio/launcher …`** over `make lint` / `make format`.
|
|
22
|
+
|
|
23
|
+
## Loop Logic
|
|
24
|
+
|
|
25
|
+
1. **Identify**:
|
|
26
|
+
- Run **`make lint`** (**`mise run lint`**, Trunk `check -a`) **or**, when Trunk is unavailable, **`npx --yes @trunkio/launcher check -a`**.
|
|
27
|
+
- Run **dead-code detection**: **`make dead-code`** (alias **`make vulture`**, runs **`uv run vulture`** using `[tool.vulture]` in `pyproject.toml`). Fix unused code the tool reports by removing it or wiring it into real usage—do not silence Vulture with broad excludes unless the user asked for that policy change.
|
|
28
|
+
2. **Analyze**: Examine the output from Trunk and Vulture, focusing on the file path, line number, and error message.
|
|
29
|
+
3. **Fix**:
|
|
30
|
+
- For formatting issues, run **`make format`** (**`mise run format-trunk`** plus `uv run ssort`) **or** **`npx --yes @trunkio/launcher fmt -a`** when using the NPM launcher.
|
|
31
|
+
- For linting violations, apply the minimum necessary change to the source code to resolve the error.
|
|
32
|
+
- Resolve findings by changing code, types, imports, or structure—not with suppressions (see **Constraints**).
|
|
33
|
+
4. **Verify**:
|
|
34
|
+
- Re-run **`make lint`** / **`npx --yes @trunkio/launcher check -a`** (Ruff, **Pyright**, Pylint, and security tools via Trunk).
|
|
35
|
+
- Re-run **`make dead-code`** until Vulture is clean or only acceptable leftover findings remain per project policy.
|
|
36
|
+
- For type-only triage, `uv run pyright` also reads `pyproject.toml` `[tool.pyright]`; prefer Trunk for CI parity.
|
|
37
|
+
- When the change affects **executable code** (behavior, types, imports beyond formatting), run **`make test`** after lint and Vulture pass (pytest-cov; see **Resources**). Same entrypoint as CI: `dev/test_python.sh`. Formatting- or comment-only edits may stop after `make lint` and **`make dead-code`**.
|
|
38
|
+
- If passed: Move to the next issue or finish if all are resolved.
|
|
39
|
+
- If failed: Analyze the new failure and repeat the loop.
|
|
40
|
+
|
|
41
|
+
## Constraints
|
|
42
|
+
|
|
43
|
+
- Do not silence Trunk/Ruff/Pyright/Pylint/Bandit/Semgrep findings with inline suppressions (for example `# noqa`, `# type: ignore`, `# pylint: disable`, `ruff: noqa`, file-level `# ruff: noqa`, or Trunk inline disable comments).
|
|
44
|
+
- Do not broaden project configuration to hide violations (for example new `[tool.ruff.lint]` ignores, Pyright `report*` toggles, or Pylint disables) unless the user explicitly asked for that policy change.
|
|
45
|
+
- Prefer **`make format`** / **`npx … fmt -a`** for auto-fixable style; otherwise fix the underlying issue the linter reports.
|
|
46
|
+
- If fixes fail after genuine attempts, stop and surface the finding for a human to decide—do not add suppressions to make CI green.
|
|
47
|
+
|
|
48
|
+
## Termination Criteria
|
|
49
|
+
|
|
50
|
+
- No more errors reported by **`make lint`** (or equivalent **`npx … check -a`**).
|
|
51
|
+
- **`make dead-code`** exits successfully (no unresolved dead-code issues per project expectations).
|
|
52
|
+
- When fixes touched executable code: **`make test`** passes.
|
|
53
|
+
- Reached max iteration limit (default: 5).
|
|
54
|
+
|
|
55
|
+
## Examples
|
|
56
|
+
|
|
57
|
+
### Scenario: Fixing a formatting violation
|
|
58
|
+
|
|
59
|
+
1. `make lint` reports formatting issues in `src/your_package/main.py`.
|
|
60
|
+
2. Agent runs `make format`.
|
|
61
|
+
3. `make lint` and `make dead-code` now pass.
|
|
62
|
+
|
|
63
|
+
### Scenario: `trunk` not on PATH
|
|
64
|
+
|
|
65
|
+
1. `make lint` fails with “trunk: command not found”.
|
|
66
|
+
2. Agent runs `make setup-tools` or `npx --yes @trunkio/launcher check -a` and continues the loop using `npx --yes @trunkio/launcher fmt -a` for formatting until checks pass.
|
|
67
|
+
|
|
68
|
+
## Resources
|
|
69
|
+
|
|
70
|
+
- [Trunk Documentation](https://docs.trunk.io/): Official documentation for the Trunk CLI.
|
|
71
|
+
- [Install Trunk CLI (including NPM launcher)](https://github.com/trunk-io/docs/blob/main/code-quality/overview/cli/getting-started/install.md): Launcher behavior and `@trunkio/launcher`.
|
|
72
|
+
- [pytest-cov](https://pytest-cov.readthedocs.io/) / [Coverage.py](https://coverage.readthedocs.io/): Test coverage used by `make test` / `make coverage`.
|