Last active
April 23, 2026 14:58
-
-
Save andreswebs/64059a3ee8d4442afddf0635cda7aae7 to your computer and use it in GitHub Desktop.
Claude YOLO scripts
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
| #!/usr/bin/env bash | |
| set -o errexit -o nounset -o pipefail | |
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| export LOCAL_MOUNTED="true" | |
| # shellcheck source=claude-lib disable=SC1091 | |
| source "${SCRIPT_DIR}/claude-lib" | |
| claude_flags=( | |
| --permission-mode bypassPermissions | |
| --dangerously-skip-permissions | |
| ) | |
| if [ -n "${DOCKER_ENTRYPOINT:-}" ]; then | |
| claude_flags=() | |
| fi | |
| if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | |
| claude "${claude_flags[@]}" "${@}" | |
| fi |
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
| #!/usr/bin/env bash | |
| [[ "${BASH_SOURCE[0]}" != "${0}" ]] || return 0 | |
| function claude() { | |
| local CLAUDE_IMAGE_URI="${CLAUDE_IMAGE_URI:-docker.io/andreswebs/claude-code}" | |
| local LOCAL_MOUNTED="${LOCAL_MOUNTED:-false}" | |
| local LOCAL_SSH="${LOCAL_SSH:-false}" | |
| local CONTAINER_WORKDIR="${CONTAINER_WORKDIR:-/workspace}" | |
| local LOCAL_WORKDIR="${LOCAL_WORKDIR:-$(pwd)}" | |
| local DOCKER_ENTRYPOINT="${DOCKER_ENTRYPOINT:-}" | |
| local DOCKER_NETWORK="${DOCKER_NETWORK:-}" | |
| local LOCAL_CLAUDE_CONFIG_DIR="${LOCAL_CLAUDE_CONFIG_DIR:-${HOME}/.claude}" | |
| local CONTAINER_CLAUDE_CONFIG_DIR="/claude" | |
| local ENABLE_TOOL_SEARCH="${ENABLE_TOOL_SEARCH:-auto}" | |
| local MCP_TIMEOUT="${MCP_TIMEOUT:-30000}" | |
| local CONTAINER_AGENT_SKILLS_DIR="${CONTAINER_CLAUDE_CONFIG_DIR}/skills" | |
| local LOCAL_AGENT_SKILLS_DIR="${LOCAL_AGENT_SKILLS_DIR:-${HOME}/.agents/skills}" | |
| local flags=( | |
| --rm | |
| --interactive | |
| --init | |
| --volume "${LOCAL_CLAUDE_CONFIG_DIR}:${CONTAINER_CLAUDE_CONFIG_DIR}" | |
| --env "MCP_TIMEOUT=${MCP_TIMEOUT}" | |
| --env "ENABLE_TOOL_SEARCH=${ENABLE_TOOL_SEARCH}" | |
| ) | |
| if [[ -t 0 ]]; then | |
| flags+=(--tty) | |
| fi | |
| if [ "${LOCAL_MOUNTED}" == "true" ]; then | |
| flags+=(--volume "${LOCAL_WORKDIR}:${CONTAINER_WORKDIR}") | |
| fi | |
| if [ "${LOCAL_SSH}" == "true" ] && [ -n "${X_DOCKER_SSH_AUTH_SOCK:-}" ]; then | |
| flags+=(--volume "${X_DOCKER_SSH_AUTH_SOCK}:${X_DOCKER_SSH_AUTH_SOCK}") | |
| flags+=(--env "SSH_AUTH_SOCK=${X_DOCKER_SSH_AUTH_SOCK}") | |
| fi | |
| if [ -n "${ANTHROPIC_MODEL:-}" ]; then | |
| flags+=(--env "ANTHROPIC_MODEL=${ANTHROPIC_MODEL}") | |
| fi | |
| # https://code.claude.com/docs/en/amazon-bedrock | |
| # https://github.com/anthropics/claude-code/issues/1859 | |
| # https://platform.claude.com/docs/en/api/beta-headers | |
| # https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool | |
| # Note: tool-search-tool has a different version depending on provider | |
| if [ -n "${CLAUDE_CODE_USE_BEDROCK:-}" ]; then | |
| local AWS_REGION="${AWS_REGION:-us-east-1}" | |
| local CLAUDE_CODE_MAX_OUTPUT_TOKENS="${CLAUDE_CODE_MAX_OUTPUT_TOKENS:-8192}" | |
| local CLAUDE_CODE_MAX_THINKING_TOKENS="${CLAUDE_CODE_MAX_THINKING_TOKENS:-1024}" | |
| local MAX_THINKING_TOKENS="${MAX_THINKING_TOKENS:-1024}" | |
| local ANTHROPIC_CUSTOM_HEADERS="anthropic-beta: tool-search-tool-2025-10-19" | |
| flags+=( | |
| --env CLAUDE_CODE_USE_BEDROCK | |
| --env AWS_BEARER_TOKEN_BEDROCK | |
| --env "AWS_REGION=${AWS_REGION}" | |
| --env "CLAUDE_CODE_MAX_OUTPUT_TOKENS=${CLAUDE_CODE_MAX_OUTPUT_TOKENS}" | |
| --env "CLAUDE_CODE_MAX_THINKING_TOKENS=${CLAUDE_CODE_MAX_THINKING_TOKENS}" | |
| --env "MAX_THINKING_TOKENS=${MAX_THINKING_TOKENS}" | |
| --env "ANTHROPIC_CUSTOM_HEADERS=${ANTHROPIC_CUSTOM_HEADERS}" | |
| ) | |
| fi | |
| if [ -n "${LOCAL_AGENT_SKILLS_DIR:-}" ] && [ -d "${LOCAL_AGENT_SKILLS_DIR}" ]; then | |
| flags+=(--volume "${LOCAL_AGENT_SKILLS_DIR}:${CONTAINER_AGENT_SKILLS_DIR}") | |
| fi | |
| if [ -n "${CLAUDE_CODE_TASK_LIST_ID:-}" ]; then | |
| flags+=(--env CLAUDE_CODE_TASK_LIST_ID) | |
| fi | |
| if [ -n "${DOCKER_ENTRYPOINT}" ]; then | |
| flags+=(--entrypoint "${DOCKER_ENTRYPOINT}") | |
| fi | |
| if [ -n "${DOCKER_NETWORK}" ]; then | |
| flags+=(--network "${DOCKER_NETWORK}") | |
| fi | |
| docker run "${flags[@]}" \ | |
| "${CLAUDE_IMAGE_URI}" \ | |
| "${@}" | |
| } |
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
| #!/usr/bin/env bash | |
| set -o errexit -o nounset -o pipefail | |
| function echo_stderr() { | |
| echo "${*}" >&2 | |
| } | |
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| PROMPT_FILE="${PROMPT_FILE:-$(pwd)/PROMPT.md}" | |
| if [ ! -f "${PROMPT_FILE}" ]; then | |
| echo_stderr "Error: prompt file not found: ${PROMPT_FILE}" | |
| exit 1 | |
| fi | |
| ## jq filters | |
| filter_stream_text='select(.type == "assistant").message.content[]? | select(.type == "text").text // empty | gsub("\n"; "\r\n") | . + "\r\n\n"' | |
| filter_final_result='select(.type == "result").result // empty' | |
| export LOCAL_MOUNTED="true" | |
| # shellcheck source=claude-lib disable=SC1091 | |
| source "${SCRIPT_DIR}/claude-lib" | |
| claude_flags=( | |
| --permission-mode bypassPermissions | |
| --dangerously-skip-permissions | |
| --output-format stream-json | |
| --verbose | |
| ) | |
| MAX_ITERATIONS="${MAX_ITERATIONS:-10}" | |
| MAX_ITERATIONS="${1:-"${MAX_ITERATIONS}"}" | |
| ITERATION=0 | |
| echo_stderr "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | |
| echo_stderr "Prompt: ${PROMPT_FILE}" | |
| if [ "${MAX_ITERATIONS}" -gt 0 ]; then | |
| echo_stderr "Max iterations: ${MAX_ITERATIONS}" | |
| else | |
| echo_stderr "Max iterations: (unlimited)" | |
| fi | |
| echo_stderr "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | |
| echo_stderr | |
| while true; do | |
| if [ "${MAX_ITERATIONS}" -gt 0 ] && [ "${ITERATION}" -ge "${MAX_ITERATIONS}" ]; then | |
| echo_stderr "Reached max iterations: ${MAX_ITERATIONS}" | |
| break | |
| fi | |
| ITERATION=$((ITERATION + 1)) | |
| echo_stderr "===================================================== ROUND ${ITERATION} =====================================================" | |
| echo_stderr | |
| echo_stderr | |
| tmpfile=$(mktemp) | |
| trap 'rm -f "${tmpfile}"' EXIT | |
| cat "${PROMPT_FILE}" | \ | |
| claude "${claude_flags[@]}" | \ | |
| grep --line-buffered '^{' | \ | |
| tee "${tmpfile}" | \ | |
| jq --unbuffered --raw-output --join-output "${filter_stream_text}" | |
| result=$(jq --raw-output "${filter_final_result}" "${tmpfile}") | |
| if [[ "${result}" == *"<promise>COMPLETE</promise>"* ]]; then | |
| echo_stderr "Work completed." | |
| echo_stderr "Total iterations: ${ITERATION}" | |
| exit 0 | |
| fi | |
| echo_stderr | |
| done |
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
| Dockerfile: <https://github.com/andreswebs-public-images/claude-code> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment