Skip to content
Merged
29 changes: 16 additions & 13 deletions infra/scripts/deploy/java-on-amazon-eks/claude-code.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
# =============================================================================
# claude-code.sh — configure Claude Code on the IDE for this workshop: the skill pack,
# the workspace MCP config (perf-sensor + EKS MCP Server) and the project permissions,
# so Claude Code started from ~/environment finds all three. No cluster needed.
# claude-code.sh — configure Claude Code on the IDE for this workshop: the skills, the
# workspace MCP config (perf-sensor + EKS MCP Server) and the project permissions, so
# Claude Code started from ~/environment finds all three. No cluster needed.
#
# Copies the two skills to ~/environment/.claude/skills/, writes ~/environment/.mcp.json
# Links each skill that skills.sh installed in ~/environment/skills/ into
# ~/environment/.claude/skills/ (run skills.sh first), writes ~/environment/.mcp.json
# (perf-sensor over streamable-http on localhost:8090, the IDE's port-forward service;
# eks-mcp read-only) and the project permissions. Idempotent.
#
Expand All @@ -17,19 +18,20 @@ set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../../.." && pwd)"
SKILLS_SRC="${REPO_ROOT}/apps/perf-sensor/skills"
ENV_DIR="${ENVIRONMENT_DIR:-${HOME}/environment}"
SKILLS_DIR="${ENV_DIR}/skills"
SKILLS_DST="${ENV_DIR}/.claude/skills"
REGION="${AWS_REGION:-us-east-1}"
NS="monitoring"
EKS_MCP_VERSION="${EKS_MCP_VERSION:-0.2.1}" # pinned; bump deliberately (ide/tools.sh prewarms the same version)

# 1. Skills -> ~/environment/.claude/skills/
# 1. Skills: ~/environment/.claude/skills/<skill> -> ~/environment/skills/<skill>
mkdir -p "${SKILLS_DST}"
for skill in java-on-eks-optimization java-on-eks-checklist; do
[ -f "${SKILLS_DIR}/${skill}/SKILL.md" ] || { echo "skill ${skill} missing in ${SKILLS_DIR}: run skills.sh first" >&2; exit 1; }
rm -rf "${SKILLS_DST:?}/${skill}"
cp -R "${SKILLS_SRC}/${skill}" "${SKILLS_DST}/${skill}"
echo "installed skill: ${SKILLS_DST}/${skill}"
ln -s "${SKILLS_DIR}/${skill}" "${SKILLS_DST}/${skill}"
echo "linked skill: ${SKILLS_DST}/${skill} -> ${SKILLS_DIR}/${skill}"
done

# 2. ~/environment/.mcp.json
Expand Down Expand Up @@ -65,8 +67,9 @@ echo "wrote ${ENV_DIR}/.mcp.json"
# name, file reads, and edits — so the investigate -> explain -> apply loop runs without
# prompts. permissions.deny closes the ways the agent could widen its own scope: Bash
# (the participant rolls out; the load runs in its own terminal), edits to the Claude
# configuration itself (.claude/**, .mcp.json) or to .git/** — Edit(path) rules cover the
# Write tool too — and Agent: a subagent answers out of the skill's sight, and its
# configuration itself (.claude/**, .mcp.json), to the skills (skills/**) or to .git/** —
# Edit(path) rules cover the Write tool too — and Agent: a subagent answers out of the
# skill's sight, and its
# hand-off text ("I'll be notified when the agent completes") ended up in an answer.
# Everything not listed prompts.
python3 - "${ENV_DIR}/.claude/settings.json" <<'PY'
Expand Down Expand Up @@ -97,7 +100,7 @@ perms["allow"] = allow
# rejects Write(path) rules at startup. Drop any Write(...) entries left by an earlier run.
deny = [r for r in perms.get("deny", []) if not r.startswith("Write(")]
for rule in ["Bash", "Agent",
"Edit(.claude/**)", "Edit(.mcp.json)", "Edit(**/.git/**)",
"Edit(.claude/**)", "Edit(.mcp.json)", "Edit(skills/**)", "Edit(**/.git/**)",
"mcp__eks-mcp__apply_yaml", "mcp__eks-mcp__manage_k8s_resource", "mcp__eks-mcp__manage_eks_stacks",
"mcp__eks-mcp__add_inline_policy", "mcp__eks-mcp__generate_app_manifest"]:
if rule not in deny:
Expand All @@ -107,9 +110,9 @@ os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, "w") as f:
json.dump(data, f, indent=2)
PY
echo "wrote ${ENV_DIR}/.claude/settings.json (MCP servers enabled; allow: sensor, eks-mcp read tools, read, edit; deny: Bash, Agent, config edits, eks-mcp write tools)"
echo "wrote ${ENV_DIR}/.claude/settings.json (MCP servers enabled; allow: sensor, eks-mcp read tools, read, edit; deny: Bash, Agent, config and skill edits, eks-mcp write tools)"

# No workspace CLAUDE.md: the app repo documents itself (unicorn-store-spring/CLAUDE.md).
# No workspace CLAUDE.md: the app repo documents itself (unicorn-store-spring/AGENTS.md).
# --allow-sensitive-data-access is required for get_pod_logs / get_k8s_events (read-only;
# --allow-write is NOT passed, so the server refuses mutations even if a write tool is
# called). Auth uses the IDE role (default iam mode). uv/uvx and the eks-mcp package are
Expand Down
6 changes: 4 additions & 2 deletions infra/scripts/deploy/java-on-amazon-eks/ide-layout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# sets "task.allowAutomaticTasks": "on" in the user settings (without it Code Editor asks
# before running the task) and "terminal.integrated.environmentChangesIndicator": "off" (the
# Claude Code extension asks to relaunch every terminal Claude runs in, which otherwise marks
# the tab with a warning badge for the rest of the session). Runs as ec2-user after
# the tab with a warning badge for the rest of the session), and hides the secondary side
# bar, which Code Editor otherwise opens empty on the right. Runs as ec2-user after
# ide/code-editor.sh. Idempotent.
# =============================================================================
set -euo pipefail
Expand All @@ -22,7 +23,8 @@ SETTINGS="${USER_DIR}/settings.json"

tmp="$(mktemp)"
jq '. + {"workbench.startupEditor": "terminal", "task.allowAutomaticTasks": "on",
"terminal.integrated.environmentChangesIndicator": "off"}' "${SETTINGS}" > "${tmp}"
"terminal.integrated.environmentChangesIndicator": "off",
"workbench.secondarySideBar.defaultVisibility": "hidden"}' "${SETTINGS}" > "${tmp}"
mv "${tmp}" "${SETTINGS}"

cat > "${USER_DIR}/tasks.json" <<'JSON'
Expand Down
4 changes: 2 additions & 2 deletions infra/scripts/deploy/java-on-amazon-eks/reset-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# 1. ~/environment/unicorn-store-spring: hard reset to the commit
# "Starting point: containerized + deployed to EKS" (made by app-prepare.sh), untracked files removed
# (Dockerfile.aot/.crac, startup-cpu-boost.yaml, listener classes ...); then
# scripts/load.sh, scripts/build.sh and CLAUDE.md are synced from the shared
# scripts/load.sh, scripts/build.sh and AGENTS.md are synced from the shared
# source (apps/unicorn-store-spring) and folded into that commit, so the
# starting point always carries the current versions.
# 2. StartupCPUBoost CRs in the app namespace deleted (created in module 2;
Expand Down Expand Up @@ -86,7 +86,7 @@ git -C "${APP_DIR}" reset -q --hard "${START_SHA}" \
# bootstrap). Sync them and fold them into the starting-point commit, so a later reset
# never brings an old script back.
SYNCED=""
for f in scripts/load.sh scripts/build.sh CLAUDE.md; do
for f in scripts/load.sh scripts/build.sh AGENTS.md; do
if [ -f "${SHARED_SRC}/${f}" ] && ! cmp -s "${SHARED_SRC}/${f}" "${APP_DIR}/${f}"; then
mkdir -p "$(dirname "${APP_DIR}/${f}")"
cp "${SHARED_SRC}/${f}" "${APP_DIR}/${f}"
Expand Down
22 changes: 22 additions & 0 deletions infra/scripts/deploy/java-on-amazon-eks/skills.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# =============================================================================
# skills.sh — install the workshop skills on the IDE for every coding agent.
#
# Copies the two skills (SKILL.md and references/) from apps/perf-sensor/skills to
# ~/environment/skills/. claude-code.sh links each skill into
# ~/environment/.claude/skills/. Run before it. No cluster needed. Idempotent.
# =============================================================================
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../../.." && pwd)"
SKILLS_SRC="${REPO_ROOT}/apps/perf-sensor/skills"
ENV_DIR="${ENVIRONMENT_DIR:-${HOME}/environment}"
SKILLS_DIR="${ENV_DIR}/skills"

mkdir -p "${SKILLS_DIR}"
for skill in java-on-eks-optimization java-on-eks-checklist; do
rm -rf "${SKILLS_DIR:?}/${skill}"
cp -R "${SKILLS_SRC}/${skill}" "${SKILLS_DIR}/${skill}"
echo "installed skill: ${SKILLS_DIR}/${skill}"
done
11 changes: 8 additions & 3 deletions infra/scripts/deploy/java-on-amazon-eks/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ done
[ -d "${ENV_DIR}/${APP_NS}/.git" ] || fail "${ENV_DIR}/${APP_NS} is not a git repo"
git -C "${ENV_DIR}/${APP_NS}" log --format=%s -n 1 2>/dev/null | grep -q "^Starting point" \
&& log_success "Starting-point commit present" || fail "starting-point commit missing"
for f in k8s/deployment.yaml scripts/load.sh scripts/build.sh CLAUDE.md; do
for f in k8s/deployment.yaml scripts/load.sh scripts/build.sh AGENTS.md; do
[ -f "${ENV_DIR}/${APP_NS}/${f}" ] || fail "missing ${f} in the participant repo"
done
grep -q "org.crac" "${ENV_DIR}/${APP_NS}/pom.xml" && fail "pom.xml still carries org.crac (de-spoil failed)"
Expand Down Expand Up @@ -63,13 +63,18 @@ echo "${M}" | jq -e '.workload.memLimitMi != null and .runtime.uptimeSeconds !=
&& log_success "perf-sensor measures ${APP_NS} (limit $(echo "${M}" | jq -r .workload.memLimitMi) Mi, uptime $(echo "${M}" | jq -r .runtime.uptimeSeconds) s)" \
|| fail "perf-sensor returned no workload/runtime facts for ${APP_NS}: $(echo "${M}" | head -c 300)"

# 6. Claude Code wiring on the IDE.
# 6. Skills for the coding agents (skills.sh).
for s in java-on-eks-checklist java-on-eks-optimization; do
[ -f "${ENV_DIR}/skills/${s}/SKILL.md" ] || fail "skill ${s} missing in ${ENV_DIR}/skills"
done

# 7. Claude Code wiring on the IDE.
[ -f "${ENV_DIR}/.mcp.json" ] && jq -e '.mcpServers["perf-sensor"] and .mcpServers["eks-mcp"]' "${ENV_DIR}/.mcp.json" >/dev/null \
&& log_success ".mcp.json has perf-sensor + eks-mcp" || fail ".mcp.json missing or incomplete"
jq -e '.permissions.deny | index("Bash")' "${ENV_DIR}/.claude/settings.json" >/dev/null 2>&1 \
&& log_success "settings.json denies Bash" || fail "settings.json does not deny Bash"
for s in java-on-eks-checklist java-on-eks-optimization; do
[ -f "${ENV_DIR}/.claude/skills/${s}/SKILL.md" ] || fail "skill ${s} missing"
[ -f "${ENV_DIR}/.claude/skills/${s}/SKILL.md" ] || fail "skill link ${ENV_DIR}/.claude/skills/${s} missing or broken"
done
command -v claude >/dev/null 2>&1 || [ -x "${HOME}/.local/bin/claude" ] || fail "claude CLI not installed"

Expand Down
29 changes: 16 additions & 13 deletions infra/scripts/deploy/java-performance/claude-code.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
# =============================================================================
# claude-code.sh — configure Claude Code on the IDE for this workshop: the skill pack,
# the workspace MCP config (perf-sensor + EKS MCP Server) and the project permissions,
# so Claude Code started from ~/environment finds all three. No cluster needed.
# claude-code.sh — configure Claude Code on the IDE for this workshop: the skills, the
# workspace MCP config (perf-sensor + EKS MCP Server) and the project permissions, so
# Claude Code started from ~/environment finds all three. No cluster needed.
#
# Copies the two skills to ~/environment/.claude/skills/, writes ~/environment/.mcp.json
# Links each skill that skills.sh installed in ~/environment/skills/ into
# ~/environment/.claude/skills/ (run skills.sh first), writes ~/environment/.mcp.json
# (perf-sensor over streamable-http on localhost:8090, the IDE's port-forward service;
# eks-mcp read-only) and the project permissions. Idempotent.
#
Expand All @@ -17,19 +18,20 @@ set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../../.." && pwd)"
SKILLS_SRC="${REPO_ROOT}/apps/perf-sensor/skills"
ENV_DIR="${ENVIRONMENT_DIR:-${HOME}/environment}"
SKILLS_DIR="${ENV_DIR}/skills"
SKILLS_DST="${ENV_DIR}/.claude/skills"
REGION="${AWS_REGION:-us-east-1}"
NS="monitoring"
EKS_MCP_VERSION="${EKS_MCP_VERSION:-0.2.1}" # pinned; bump deliberately (ide/tools.sh prewarms the same version)

# 1. Skills -> ~/environment/.claude/skills/
# 1. Skills: ~/environment/.claude/skills/<skill> -> ~/environment/skills/<skill>
mkdir -p "${SKILLS_DST}"
for skill in java-on-eks-optimization java-on-eks-checklist; do
[ -f "${SKILLS_DIR}/${skill}/SKILL.md" ] || { echo "skill ${skill} missing in ${SKILLS_DIR}: run skills.sh first" >&2; exit 1; }
rm -rf "${SKILLS_DST:?}/${skill}"
cp -R "${SKILLS_SRC}/${skill}" "${SKILLS_DST}/${skill}"
echo "installed skill: ${SKILLS_DST}/${skill}"
ln -s "${SKILLS_DIR}/${skill}" "${SKILLS_DST}/${skill}"
echo "linked skill: ${SKILLS_DST}/${skill} -> ${SKILLS_DIR}/${skill}"
done

# 2. ~/environment/.mcp.json
Expand Down Expand Up @@ -65,8 +67,9 @@ echo "wrote ${ENV_DIR}/.mcp.json"
# name, file reads, and edits — so the investigate -> explain -> apply loop runs without
# prompts. permissions.deny closes the ways the agent could widen its own scope: Bash
# (the participant rolls out; the load runs in its own terminal), edits to the Claude
# configuration itself (.claude/**, .mcp.json) or to .git/** — Edit(path) rules cover the
# Write tool too — and Agent: a subagent answers out of the skill's sight, and its
# configuration itself (.claude/**, .mcp.json), to the skills (skills/**) or to .git/** —
# Edit(path) rules cover the Write tool too — and Agent: a subagent answers out of the
# skill's sight, and its
# hand-off text ("I'll be notified when the agent completes") ended up in an answer.
# Everything not listed prompts.
python3 - "${ENV_DIR}/.claude/settings.json" <<'PY'
Expand Down Expand Up @@ -97,7 +100,7 @@ perms["allow"] = allow
# rejects Write(path) rules at startup. Drop any Write(...) entries left by an earlier run.
deny = [r for r in perms.get("deny", []) if not r.startswith("Write(")]
for rule in ["Bash", "Agent",
"Edit(.claude/**)", "Edit(.mcp.json)", "Edit(**/.git/**)",
"Edit(.claude/**)", "Edit(.mcp.json)", "Edit(skills/**)", "Edit(**/.git/**)",
"mcp__eks-mcp__apply_yaml", "mcp__eks-mcp__manage_k8s_resource", "mcp__eks-mcp__manage_eks_stacks",
"mcp__eks-mcp__add_inline_policy", "mcp__eks-mcp__generate_app_manifest"]:
if rule not in deny:
Expand All @@ -107,9 +110,9 @@ os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, "w") as f:
json.dump(data, f, indent=2)
PY
echo "wrote ${ENV_DIR}/.claude/settings.json (MCP servers enabled; allow: sensor, eks-mcp read tools, read, edit; deny: Bash, Agent, config edits, eks-mcp write tools)"
echo "wrote ${ENV_DIR}/.claude/settings.json (MCP servers enabled; allow: sensor, eks-mcp read tools, read, edit; deny: Bash, Agent, config and skill edits, eks-mcp write tools)"

# No workspace CLAUDE.md: the app repo documents itself (unicorn-store-spring/CLAUDE.md).
# No workspace CLAUDE.md: the app repo documents itself (unicorn-store-spring/AGENTS.md).
# --allow-sensitive-data-access is required for get_pod_logs / get_k8s_events (read-only;
# --allow-write is NOT passed, so the server refuses mutations even if a write tool is
# called). Auth uses the IDE role (default iam mode). uv/uvx and the eks-mcp package are
Expand Down
12 changes: 7 additions & 5 deletions infra/scripts/deploy/java-performance/ide-layout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# =============================================================================
# ide-layout.sh — the two terminals of the session, set at bootstrap, nothing in
# ~/environment: the terminal in the editor area (Code Editor's startup editor, a zsh in
# ~/environment) is where Claude Code runs; a user-level task opens the Shell terminal in
# the bottom panel each time the IDE opens.
# ~/environment) is the Agent terminal, where the AI agent runs; a user-level task opens the
# Shell terminal in the bottom panel each time the IDE opens.
#
# Writes ~/.code-editor-server/data/User/tasks.json (task "Shell", runOn folderOpen) and
# sets "task.allowAutomaticTasks": "on" in the user settings (without it Code Editor asks
# before running the task) and "terminal.integrated.environmentChangesIndicator": "off" (the
# Claude Code extension asks to relaunch every terminal Claude runs in, which otherwise marks
# the tab with a warning badge for the rest of the session). Runs as ec2-user after
# the tab with a warning badge for the rest of the session), and hides the secondary side
# bar, which Code Editor otherwise opens empty on the right. Runs as ec2-user after
# ide/code-editor.sh. Idempotent.
# =============================================================================
set -euo pipefail
Expand All @@ -22,7 +23,8 @@ SETTINGS="${USER_DIR}/settings.json"

tmp="$(mktemp)"
jq '. + {"workbench.startupEditor": "terminal", "task.allowAutomaticTasks": "on",
"terminal.integrated.environmentChangesIndicator": "off"}' "${SETTINGS}" > "${tmp}"
"terminal.integrated.environmentChangesIndicator": "off",
"workbench.secondarySideBar.defaultVisibility": "hidden"}' "${SETTINGS}" > "${tmp}"
mv "${tmp}" "${SETTINGS}"

cat > "${USER_DIR}/tasks.json" <<'JSON'
Expand All @@ -41,4 +43,4 @@ cat > "${USER_DIR}/tasks.json" <<'JSON'
]
}
JSON
log_success "IDE layout: Claude Code terminal in the editor area, Shell terminal in the panel"
log_success "IDE layout: Agent terminal in the editor area, Shell terminal in the panel"
Loading
Loading