Alexander Thiele

Alexander Thiele

Techi 👨‍💻 Startup Enthusiast, Entrepreneur, Co-Founder. Creating Company & Engineering Culture & Flutter fan 🤓

Detailed Analysis: after_edit.sh Script#

The after_edit.sh script is the heart of the automation. It processes the tool output from Claude and performs code quality checks on Dart files.

Script Breakdown#

1. Input Parsing#

The script starts by reading the JSON input provided by Claude on stdin and extracts the tool name and the modified file path using jq.

INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // empty')
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')

2. Filtering for Dart Files#

The script specifically targets .dart files that exist on disk.

if [[ -n "$FILE_PATH" && "$FILE_PATH" == *.dart && -f "$FILE_PATH" ]]; then

3. Automatic Formatting#

It runs fvm dart format to ensure the code adheres to standard styling rules immediately after being written.

fvm dart format "$FILE_PATH" > /dev/null 2>&1

4. Static Analysis#

It performs a dart analyze on the specific file. If issues are found, it captures the output.

OUTPUT=$(fvm dart analyze "$FILE_PATH" 2>&1)

5. Conditional Response#

If "No issues found!" is detected, the script exits normally (exit 0), allowing Claude to proceed. If there are issues, it constructs a JSON response to block the tool and report the errors.