Skip to content

evanca/flutter-ai-rules / skills/code-review

code-review

Verified

Use when asked to review a PR, MR, branch, or diff, audit changed files, or check code quality.

FileKindSize
SKILL.mdskill md9.4 KB
references/github-posting.mdmarkdown5.4 KB
references/gitlab-posting.mdmarkdown4.2 KB
scripts/protect-token.shexecutablescript2.7 KB

scripts/protect-token.sh

View on GitHub
#!/usr/bin/env bash
#
# PreToolUse hook for the code-review skill.
#
# Goal: the agent may confirm a review-bot token is configured and report its
# LENGTH, but must never reveal the token VALUE. This hook enforces that
# deterministically in the harness rather than relying on instructions alone.
#
# Allowed:  existence/length checks via ${#GITLAB_TOKEN} / ${#GITHUB_TOKEN},
#           and passing the token to curl as an auth header.
# Blocked:  echo/printf/cat/tee of the token value, environment dumps, and
#           curl -v/--verbose/--trace (which print the auth header).
#
# The hook reads the PreToolUse event JSON on stdin and, to block a call, prints
# a permissionDecision=deny object (see code.claude.com/docs/en/hooks). Any other
# Bash command falls through (exit 0) to the normal permission flow.

input="$(cat)"

# Extract the Bash command. If jq is unavailable, scan the raw event instead so
# enforcement still applies (it just may be slightly more conservative).
if command -v jq >/dev/null 2>&1; then
  cmd="$(printf '%s' "$input" | jq -r '.tool_input.command // ""' 2>/dev/null)"
else
  cmd="$input"
fi

deny() {
  # Reasons must contain no double quotes or backslashes (kept JSON-safe inline).
  printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"%s"}}\n' "$1"
  exit 0
}

names='GITLAB_TOKEN|GITHUB_TOKEN'

# 1) curl with verbose/trace prints the Authorization / PRIVATE-TOKEN header.
if printf '%s' "$cmd" | grep -Eq 'curl' \
   && printf '%s' "$cmd" | grep -Eq '(^|[[:space:]])(-v|--verbose|--trace[^[:space:]]*)([[:space:]]|$)'; then
  deny "curl -v/--verbose/--trace prints the auth header, which exposes the token. Re-run the request without verbose/trace flags."
fi

# 2) Environment dumps that would include the token.
if printf '%s' "$cmd" | grep -Eq "printenv[[:space:]]+($names)([[:space:]]|$)"; then
  deny "Printing the token with printenv is not allowed. Confirm it is set and how long it is with the length form instead."
fi
if printf '%s' "$cmd" | grep -Eq '(^|[|;&]|[[:space:]])(printenv|env|set|export[[:space:]]+-p|declare[[:space:]]+-p)[[:space:]]*(\||$)'; then
  deny "Dumping the whole environment can expose the token. Reference a specific variable length instead."
fi

# 3) Token VALUE passed to a printing/writing command. The length form is allowed
#    because the regex requires the value form ($NAME or ${NAME...}), and ${#NAME}
#    does not match it.
if printf '%s' "$cmd" | grep -Eq "(echo|printf|print|cat|tee)[[:space:]][^|;&]*[\$][{]?($names)"; then
  deny "Refusing to print the token value. Verify existence/length with the length form, but never echo/printf/cat the value itself."
fi

exit 0
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall