Last active
January 15, 2026 13:59
-
-
Save GuGuss/071863b598739f2b885c9b17445d7e34 to your computer and use it in GitHub Desktop.
claude-source-operation.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Color codes for output | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| CYAN='\033[0;36m' | |
| NC='\033[0m' | |
| # Check if ANTHROPIC_API_KEY is set | |
| if [ -z "$ANTHROPIC_API_KEY" ]; then | |
| echo -e "${RED}ERROR: ANTHROPIC_API_KEY environment variable is not set${NC}" | |
| echo "" | |
| echo "To fix this issue:" | |
| echo "1. Set the variable as a project variable in your Upsun console" | |
| echo "2. Make sure it's marked as 'sensitive' and 'available during build'" | |
| echo "3. The variable name should be exactly: env:ANTHROPIC_API_KEY" | |
| echo "" | |
| exit 1 | |
| fi | |
| # Check if INPUT variable is provided | |
| if [ -z "$INPUT" ]; then | |
| echo -e "${RED}ERROR: No input prompt provided${NC}" | |
| exit 1 | |
| fi | |
| echo -e "${CYAN}Current directory: $(pwd)${NC}" | |
| echo -e "${CYAN}User prompt: ${INPUT}${NC}" | |
| # Create Claude configuration directory | |
| mkdir -p .claude | |
| echo '{"permissions": {"defaultMode": "bypassPermissions"}}' > .claude/settings.json | |
| # Build enhanced prompt | |
| ENHANCED_PROMPT="You are working in an Upsun deployment environment in the $(basename $(pwd)) application. | |
| User request: ${INPUT} | |
| Important instructions: | |
| 1. Make the requested code changes to the codebase | |
| 2. After making changes, review them carefully | |
| 3. Commit ALL changes with a clear, descriptive commit message | |
| 4. Start the commit message with an appropriate emoji | |
| 5. After committing, explain what you changed and why | |
| Please proceed with implementing these changes now." | |
| # Execute Claude | |
| echo -e "${CYAN}Executing Claude...${NC}" | |
| echo "" | |
| claude "${ENHANCED_PROMPT}" | |
| CLAUDE_EXIT=$? | |
| echo "" | |
| echo -e "${CYAN}Claude finished with exit code: ${CLAUDE_EXIT}${NC}" | |
| echo "" | |
| # Check for commits | |
| echo -e "${CYAN}Checking for changes...${NC}" | |
| COMMITS=$(git log --oneline --since="1 minute ago" 2>/dev/null | wc -l) | |
| if [ "$COMMITS" -gt 0 ]; then | |
| echo -e "${GREEN}Commits created:${NC}" | |
| git log --oneline --since="1 minute ago" | |
| echo "" | |
| echo -e "${GREEN}Latest commit details:${NC}" | |
| git show --stat HEAD | |
| echo "" | |
| echo -e "${CYAN}Detailed changes (git diff):${NC}" | |
| git show HEAD --color=always | |
| else | |
| echo -e "${CYAN}Checking for uncommitted changes...${NC}" | |
| if ! git diff --quiet 2>/dev/null; then | |
| echo -e "${YELLOW}Uncommitted changes found:${NC}" | |
| git diff --stat | |
| echo "" | |
| echo -e "${CYAN}Detailed changes (git diff):${NC}" | |
| git diff --color=always | |
| else | |
| echo -e "${YELLOW}No changes detected${NC}" | |
| fi | |
| fi | |
| echo "" | |
| echo -e "${GREEN}Operation completed!${NC}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment