From ebef98c80d94a1bc868fda1df5ddcf42bc3e0d78 Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Fri, 26 Jun 2026 17:48:32 +0100 Subject: [PATCH] fix: drop redundant array spread in single-module agent tools (SonarCloud) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Object.values() already returns a fresh array, so [...Object.values(x)] is a redundant clone. Use Object.values(x) directly in the two single-module agents (github-pr-label-actions, triage-github-actions) and update the create-agent SOP skill to teach the non-spread form. The jira examples keep the spread — there it concatenates multiple tool modules, which is a legitimate use. --- .claude/skills/create-agent/SKILL.md | 7 ++++--- .../github-pr-label-actions/src/agents/pr-label-actions.ts | 2 +- examples/triage-github-actions/src/agents/github-triage.ts | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.claude/skills/create-agent/SKILL.md b/.claude/skills/create-agent/SKILL.md index 406def8..1042a31 100644 --- a/.claude/skills/create-agent/SKILL.md +++ b/.claude/skills/create-agent/SKILL.md @@ -81,9 +81,10 @@ Mirror the closest example. The shape is always: provider is Bedrock — do NOT default to `anthropic/` + `ANTHROPIC_API_KEY`). - `const cwd = process.env.SKILLS_DIR ?? process.cwd();` then `sandbox: local({ cwd })` so skills are discoverable and overridable. - - `tools: [...Object.values(xTools)]` — so the tool module must export ONLY - tools. Put pure helpers in a separate `helpers.ts` (a non-tool export here - becomes a bogus tool; `tsc` will catch it). + - `tools: Object.values(xTools)` (it already returns a fresh array — don't + spread-clone it; for several modules use `[...Object.values(a), ...Object.values(b)]`). + The tool module must export ONLY tools — put pure helpers in a separate + `helpers.ts` (a non-tool export here becomes a bogus tool; `tsc` will catch it). 2. **AGENTS.md** — one or two lines of always-on framing ("You do X. Use the skill."). 3. **Skill** `.agents/skills//SKILL.md` — frontmatter (`name`, diff --git a/examples/github-pr-label-actions/src/agents/pr-label-actions.ts b/examples/github-pr-label-actions/src/agents/pr-label-actions.ts index 6da051f..8e527cf 100644 --- a/examples/github-pr-label-actions/src/agents/pr-label-actions.ts +++ b/examples/github-pr-label-actions/src/agents/pr-label-actions.ts @@ -22,5 +22,5 @@ const cwd = process.env.SKILLS_DIR ?? process.cwd(); export default defineAgent(() => ({ model: 'amazon-bedrock/us.anthropic.claude-sonnet-4-6', sandbox: local({ cwd }), - tools: [...Object.values(githubTools)], + tools: Object.values(githubTools), })); diff --git a/examples/triage-github-actions/src/agents/github-triage.ts b/examples/triage-github-actions/src/agents/github-triage.ts index cdd447b..9481ed2 100644 --- a/examples/triage-github-actions/src/agents/github-triage.ts +++ b/examples/triage-github-actions/src/agents/github-triage.ts @@ -18,5 +18,5 @@ const cwd = process.env.SKILLS_DIR ?? process.cwd(); export default defineAgent(() => ({ model: 'amazon-bedrock/us.anthropic.claude-sonnet-4-6', sandbox: local({ cwd }), - tools: [...Object.values(githubTools)], + tools: Object.values(githubTools), }));