- Resolve Python 3.11+ through shared Resolve-Python.ps1/resolve-python.sh, which probe python, python3 and py -3 and skip the Windows Store alias. Build and capability checks fail early with an actionable message; doctor reports missing Python and the skipped hooks. - Fix check-capabilities.sh comparing only the major version. - Register Validate-CommandSafety as a PreToolUse hook for Claude and Codex; shared logic in command-safety.py catches rm -rf variants, git reset --hard, git clean -f, Remove-Item -Recurse, del/rd /s /q and nested shells. - Replace duplicated placeholder chains in both builds with adapters/placeholders.tsv. - Restore shell parity: add test-capabilities.sh, rename credentials.ps1 to with-credential.ps1 and qmd-warm.sh to start-qmd-warm.sh. - CI: build once and pass generated/ as an artifact, lint Python with ruff and JavaScript modules with node --check, require SHA pins for all actions. - Add evals for all own skills and update documentation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
4.4 KiB
JSON
48 lines
4.4 KiB
JSON
{
|
|
"skill_name": "performance-review",
|
|
"evals": [
|
|
{
|
|
"id": 1,
|
|
"prompt": "Review this change for performance. It runs on every product page view (~2k req/s at peak); `relatedIds` is typically 20-40 items.\n\n```ts\nasync function getRelatedProducts(relatedIds: string[]) {\n const products = [];\n for (const id of relatedIds) {\n products.push(await productApi.get(id)); // HTTP call, ~15ms p50\n }\n return products.filter(p => p.inStock).sort((a, b) => a.rank - b.rank);\n}\n```",
|
|
"expected_output": "Should identify the execution path frequency (every page view, 2k req/s) and input size (20-40). Should trace the sequential network calls: 20-40 x ~15 ms = roughly 300-600 ms added latency per request, plus 40-80k outbound calls/s. Should clearly label this as a reasoned estimate, not a measurement. Should propose the smallest useful correction (batch endpoint or bounded parallel requests) and check that ordering and failure behavior are preserved. Should not focus on micro-optimizing the filter/sort of 40 items.",
|
|
"assertions": [
|
|
"Identifies sequential awaited HTTP calls in the loop as the main cost",
|
|
"Estimates added latency in the range of roughly 300 to 600 ms per request from 20-40 calls at 15 ms",
|
|
"Labels the latency figure as an estimate rather than a measurement",
|
|
"Considers the outbound call volume at 2k requests per second",
|
|
"Proposes batching or bounded concurrency as the correction",
|
|
"Addresses failure or ordering behavior of the proposed change",
|
|
"Does not recommend optimizing the filter or sort of a few dozen items"
|
|
],
|
|
"files": []
|
|
},
|
|
{
|
|
"id": 2,
|
|
"prompt": "We added an in-memory cache to speed up permission checks:\n\n```csharp\nprivate static readonly Dictionary<Guid, UserPermissions> _cache = new();\n\npublic UserPermissions Get(Guid userId)\n{\n if (!_cache.TryGetValue(userId, out var p))\n {\n p = _repo.Load(userId);\n _cache[userId] = p;\n }\n return p;\n}\n```\nThe service is an ASP.NET Core singleton handling concurrent requests; permissions can be changed by admins at any time. Benchmarks show the check went from 4 ms to 0.01 ms. Ship it?",
|
|
"expected_output": "Should check whether the cache preserves invalidation and correctness: permission changes are never reflected (no invalidation or expiry), which is a correctness and security risk. Should flag that Dictionary is not thread-safe under concurrent writes from a singleton. Should flag unbounded memory growth with the number of users. Should acknowledge the benchmark as a measured result but note it does not cover correctness or memory growth. Should propose a minimal fix (thread-safe bounded cache with expiry and invalidation on permission change).",
|
|
"assertions": [
|
|
"Flags missing invalidation so admin permission changes are not reflected",
|
|
"Flags that Dictionary is not thread-safe for concurrent writes in a singleton",
|
|
"Flags unbounded memory growth of the static cache",
|
|
"Treats the 4 ms to 0.01 ms figure as a measured result while noting it does not prove correctness",
|
|
"Proposes a bounded, thread-safe cache with expiry or explicit invalidation",
|
|
"Does not approve shipping as-is"
|
|
],
|
|
"files": []
|
|
},
|
|
{
|
|
"id": 3,
|
|
"prompt": "Performance review please. This runs once at app startup to load 12 feature flags from a config file:\n\n```python\nflags = {}\nfor line in open('flags.txt').read().splitlines():\n k, v = line.split('=')\n flags[k.strip()] = v.strip().lower() == 'true'\n```\nA colleague says we should rewrite it with a compiled regex and a generator for speed.",
|
|
"expected_output": "Execution frequency is once at startup with 12 lines; cost is negligible. Should say there is no meaningful performance concern and not recommend the micro-optimization, since it lacks plausible user impact. Should not recommend a benchmark because it would not answer a concrete uncertainty. May mention non-performance observations only if clearly separated.",
|
|
"assertions": [
|
|
"Identifies that the code runs once at startup on about 12 lines",
|
|
"Concludes there is no meaningful performance risk",
|
|
"Does not recommend the compiled regex or generator rewrite for performance",
|
|
"Does not recommend a benchmark or profiler for this code",
|
|
"Does not present theoretical concerns as confirmed regressions"
|
|
],
|
|
"files": []
|
|
}
|
|
]
|
|
}
|