add: upload new research files#3
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive set of demo and tutorial materials for a Claude Code engineering lecture, including a mock training script, configuration files (CLAUDE.md, settings.json), custom skills, presentation slides, and speaker notes. The review feedback highlights several robust improvements for the Python script and configuration: initializing the loss variable in train.py to avoid a potential NameError when epochs is non-positive, separating imports to adhere to PEP 8, explicitly defining the UTF-8 encoding when writing JSON files, and quoting the $CLAUDE_TOOL_INPUT shell variable in settings.json to prevent shell-splitting bugs.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| best_acc = 0.0 | ||
| for ep in range(1, epochs + 1): |
There was a problem hiding this comment.
If epochs is set to 0 or a negative value, the training loop will not execute, and the variable loss will never be defined. This will result in a NameError when attempting to round and log loss after the loop. Initializing loss beforehand prevents this potential runtime crash.
| best_acc = 0.0 | |
| for ep in range(1, epochs + 1): | |
| best_acc = 0.0 | |
| loss = 0.0 | |
| for ep in range(1, epochs + 1): |
| @@ -0,0 +1,35 @@ | |||
| import json, time, random, argparse | |||
There was a problem hiding this comment.
According to PEP 8, imports should be on separate lines rather than grouped on a single line. This improves readability and makes tracking changes easier.
import argparse
import json
import random
import timeReferences
- PEP 8: Imports should usually be on separate lines. (link)
|
|
||
| out = Path("results") / f"run_{seed:03d}.json" | ||
| out.parent.mkdir(exist_ok=True) | ||
| out.write_text(json.dumps(results, indent=2)) |
There was a problem hiding this comment.
When writing text files, it is highly recommended to specify an explicit encoding (such as 'utf-8') rather than relying on the platform's default encoding. This prevents potential encoding issues on different operating systems (e.g., Windows).
| out.write_text(json.dumps(results, indent=2)) | |
| out.write_text(json.dumps(results, indent=2), encoding="utf-8") |
| "afterToolUse": [ | ||
| { | ||
| "matcher": "Edit|Write", | ||
| "command": "echo '[hook] File modified: checking Python syntax...' && python3 -m py_compile \"$(echo $CLAUDE_TOOL_INPUT | python3 -c \"import sys,json; d=json.load(sys.stdin); print(d.get('file_path',''))\" 2>/dev/null || echo '')\" 2>&1 | head -5 || true" |
There was a problem hiding this comment.
The shell variable $CLAUDE_TOOL_INPUT is unquoted inside the subshell. If the JSON input contains spaces, wildcards, or other shell-active characters, the shell will perform word splitting and globbing, which can lead to syntax errors or unexpected behavior. Wrapping it in double quotes ensures robust execution.
| "command": "echo '[hook] File modified: checking Python syntax...' && python3 -m py_compile \"$(echo $CLAUDE_TOOL_INPUT | python3 -c \"import sys,json; d=json.load(sys.stdin); print(d.get('file_path',''))\" 2>/dev/null || echo '')\" 2>&1 | head -5 || true" | |
| "command": "echo '[hook] File modified: checking Python syntax...' && python3 -m py_compile \"$(echo \\\"$CLAUDE_TOOL_INPUT\\\" | python3 -c \"import sys,json; d=json.load(sys.stdin); print(d.get('file_path',''))\" 2>/dev/null || echo '')\" 2>&1 | head -5 || true" |
No description provided.