RussellSpitzer commented on code in PR #15822:
URL: https://github.com/apache/iceberg/pull/15822#discussion_r3010597974


##########
AGENTS.md:
##########
@@ -159,6 +159,7 @@ The `api/` module has the strongest stability guarantees — 
breaking changes ar
 - One concern per PR. Unrelated whitespace, import, or formatting changes go 
in separate PRs.
 - Keep first version of a PR minimal — defer recovery, optimization, and edge 
cases to follow-ups.
 - Commit messages describe the *what* and *why*, not implementation details.
+- Before creating or amending a commit, run the relevant code style check and 
fix any violations.

Review Comment:
   @manuzhang The idea here is that if you put it a pre-commit hook, the agent 
doesn't have to have any instructions, it will always just get cleaned up 
automatically. 
   
   Anything we add to this file is essentially extra token cost every single 
time you go to the LLM. This is a two fold problem. 
   
   1. We reduce the context space for valuable context
   2. We increase the cost of using our agent.md
   
   If we leave it in agent.md we are essentially just wasting tokens telling it 
to do something which can programmatically be invoked without the agent having 
to be aware of it.
   
   
   So if instead you do something like 
   
   ```sh
   #!/bin/sh
   #
   # Pre-commit hook that runs spotless apply to format code before committing
   #
   # Check if this is the Apache Iceberg project
   if [ ! -f "build.gradle" ] || ! grep -q 'group = "org.apache.iceberg"' 
build.gradle 2>/dev/null; then
       exit 0
   fi
   # Capture the list of staged files before spotless modifies them
   STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)
   if [ -z "$STAGED_FILES" ]; then
       exit 0
   fi
   echo "Running spotlessApply..."
   ./gradlew -DallModules spotlessApply
   if [ $? -ne 0 ]; then
       echo "ERROR: spotlessApply failed. Please fix the issues and try again."
       exit 1
   fi
   # Re-stage only the files that were originally staged (in case spotless 
reformatted them)
   echo "$STAGED_FILES" | xargs git add
   echo "spotlessApply complete."
   exit 0
   ```
   
   You don't need to tell your agent anything at all it just always runs 
spotless apply when you commit
   
   _- Note I use a lot of worktrees and clones so I use the above hook globally 
just so whenever i'm running on any iceberg repo it does the spotless.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to