Last active
July 22, 2026 05:27
-
-
Save dvashchuk/b5f8494764a8fb18651622206e205789 to your computer and use it in GitHub Desktop.
640K ought to be enough for anybody. 50$ too
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
| code-review-graph-build() { | |
| command -v code-review-graph || pipx install code-review-graph | |
| code-review-graph install | |
| code-review-graph build | |
| } |
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
| import json | |
| import os | |
| import sys | |
| HOME = os.path.expanduser("~") | |
| # 1. Resolve OS-specific paths for desktop UI profiles (Cursor & VS Code Copilot) | |
| if sys.platform == "darwin": # macOS | |
| CURSOR_UI_PATH = os.path.join(HOME, "Library/Application Support/Cursor/User/settings.json") | |
| COPILOT_VSCODE_PATH = os.path.join(HOME, "Library/Application Support/Code/User/settings.json") | |
| elif sys.platform.startswith("linux"): # Linux | |
| CURSOR_UI_PATH = os.path.join(HOME, ".config/Cursor/User/settings.json") | |
| COPILOT_VSCODE_PATH = os.path.join(HOME, ".config/Code/User/settings.json") | |
| elif sys.platform == "win32": # Windows | |
| APPDATA = os.environ.get("APPDATA", os.path.join(HOME, "AppData/Roaming")) | |
| CURSOR_UI_PATH = os.path.join(APPDATA, "Cursor/User/settings.json") | |
| COPILOT_VSCODE_PATH = os.path.join(APPDATA, "Code/User/settings.json") | |
| else: | |
| print(f"Unsupported OS platform: {sys.platform}") | |
| sys.exit(1) | |
| # Central map for JSON-backed configuration pathways | |
| JSON_CONFIG_MAP = { | |
| "Cursor CLI": os.path.join(HOME, ".cursor/cli-config.json"), | |
| "Cursor UI": CURSOR_UI_PATH, | |
| "Claude Code": os.path.join(HOME, ".claude/settings.json"), | |
| "GitHub Copilot (VS Code)": COPILOT_VSCODE_PATH, | |
| "GitHub Copilot CLI": os.path.join(HOME, ".copilot/config.json"), | |
| } | |
| CODEX_TOML_PATH = os.path.join(HOME, ".codex/config.toml") | |
| def modify_json(file_path, update_fn): | |
| """Safely reads, modifies, and saves a JSON config file.""" | |
| os.makedirs(os.path.dirname(file_path), exist_ok=True) | |
| try: | |
| with open(file_path, "r") as f: | |
| data = json.load(f) | |
| except (FileNotFoundError, json.JSONDecodeError): | |
| data = {} | |
| update_fn(data) | |
| with open(file_path, "w") as f: | |
| json.dump(data, f, indent=2) | |
| # --- JSON Modifier Definitions --- | |
| def update_cursor_cli(data): | |
| if "attribution" not in data or not isinstance(data["attribution"], dict): | |
| data["attribution"] = {} | |
| data["attribution"]["attributeCommitsToAgent"] = False | |
| data["attribution"]["attributePRsToAgent"] = False | |
| data["permissions"] = { | |
| "allow": ["Shell(*)", "Mcp(ScraplingServer:get)"], | |
| "deny": [] | |
| } | |
| def update_cursor_ui(data): | |
| data["cursor.attribution.attributeCommitsToAgent"] = False | |
| data["cursor.attribution.attributePRsToAgent"] = False | |
| def update_claude_code(data): | |
| if "attribution" not in data or not isinstance(data["attribution"], dict): | |
| data["attribution"] = {} | |
| data["attribution"]["commit"] = "" | |
| data["attribution"]["pr"] = "" | |
| def update_copilot_vscode(data): | |
| data["github.copilot.chat.commitMessageGeneration.enabled"] = False | |
| def update_copilot_cli(data): | |
| data["auto_execute"] = False | |
| data["analytics"] = "disabled" | |
| # --- TOML Modifier for Codex (CLI & App Shared Configuration) --- | |
| def update_codex_toml(file_path): | |
| """Parses and updates Codex TOML properties without erasing custom blocks.""" | |
| os.makedirs(os.path.dirname(file_path), exist_ok=True) | |
| content = "" | |
| if os.path.exists(file_path): | |
| with open(file_path, "r") as f: | |
| content = f.read() | |
| lines = content.splitlines() | |
| # 1. Force approval confirmations for security, keeping workflows predictable | |
| if not any(line.strip().startswith("approval_policy") for line in lines): | |
| lines.insert(0, 'approval_policy = "on-request"') | |
| # 2. Block Codex-generated git commits and metadata injection trailers | |
| if "[features]" in content: | |
| for idx, line in enumerate(lines): | |
| if line.strip() == "[features]": | |
| if not any("codex_git_commit" in l for l in lines[idx:idx+15]): | |
| lines.insert(idx + 1, "codex_git_commit = false") | |
| break | |
| else: | |
| lines.extend(["\n[features]", "codex_git_commit = false"]) | |
| # 3. Mount the Scrapling Server into Codex's MCP architecture | |
| if "[mcp_servers.ScraplingServer]" not in content: | |
| lines.extend([ | |
| "\n[mcp_servers.ScraplingServer]", | |
| 'command = "npx"', | |
| 'args = ["-y", "@upstash/scrapling-mcp-server"]', | |
| 'enabled = true' | |
| ]) | |
| with open(file_path, "w") as f: | |
| f.write("\n".join(lines) + "\n") | |
| # --- Execution Run --- | |
| print("Configuring ecosystem restrictions & agent usability...\n") | |
| # Run JSON processors | |
| updaters = { | |
| "Cursor CLI": update_cursor_cli, | |
| "Cursor UI": update_cursor_ui, | |
| "Claude Code": update_claude_code, | |
| "GitHub Copilot (VS Code)": update_copilot_vscode, | |
| "GitHub Copilot CLI": update_copilot_cli, | |
| } | |
| for tool, path in JSON_CONFIG_MAP.items(): | |
| try: | |
| modify_json(path, updaters[tool]) | |
| print(f" [SUCCESS] Configured {tool} -> {path}") | |
| except Exception as e: | |
| print(f" [ERROR] Failed {tool}: {e}") | |
| # Run Codex TOML processor | |
| try: | |
| update_codex_toml(CODEX_TOML_PATH) | |
| print(f" [SUCCESS] Configured OpenAI Codex (CLI & App) -> {CODEX_TOML_PATH}") | |
| except Exception as e: | |
| print(f" [ERROR] Failed Codex configuration: {e}") | |
| print("\nAll profiles structural adjustments completed. Restart active workspaces to apply.") |
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
| #!/bin/bash | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| # WHAT THIS SCRIPT INSTALLS | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| # Tool Targets Token impact | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| # Scrapling MCP Claude/VSCode/OC ~59% fewer on web fetches | |
| # Strips HTML noise; returns markdown content only | |
| # | |
| # RTK Claude Code (global) Compresses CLI/tool output | |
| # before it enters the context window | |
| # | |
| # Context7 MCP Claude/VSCode/OC ~95% fewer on doc lookups | |
| # 1-5KB structured result vs 50-100KB raw HTML | |
| # | |
| # LSP servers Claude Code + OpenCode ~70-99% fewer on code nav | |
| # gopls Exact go-to-definition instead of grepping 50+ files | |
| # pyright Type info + diagnostics without reading whole files | |
| # typescript-lsp Rename/references semantically instead of regex search | |
| # | |
| # Claude plugins Claude Code only | |
| # code-review Structured PR review skill | |
| # superpowers Extended agent capabilities | |
| # modern-go-guidelines JetBrains Go style rules | |
| # | |
| # Config patches No token impact — quality of life | |
| # CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50 compact context at 50% instead of 95% | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| # Documentation: | |
| # MCP | |
| # https://opencode.ai/docs/mcp-servers/ | |
| # https://docs.github.com/en/copilot/concepts/context/mcp | |
| # Language Server Protocol | |
| # https://opencode.ai/docs/lsp/ | |
| # https://code.visualstudio.com/api/language-extensions/language-server-extension-guide | |
| # Prerequisites | |
| if command -v brew >/dev/null; then | |
| brew install pipx go node jq | |
| elif command -v apt-get >/dev/null; then | |
| sudo apt-get install -y pipx golang-go nodejs jq | |
| elif command -v dnf >/dev/null; then | |
| sudo dnf install -y python3-pipx golang nodejs jq | |
| fi | |
| # Scrapling replaces Claude's built-in WebFetch with filtered, markdown-converted content. | |
| # WebFetch dumps entire HTML pages (nav, footer, scripts, ads — 50-100KB). | |
| # Scrapling's main_content_only=true + markdown extraction returns just the content (~20-40KB). | |
| # Scrapling MCP Token Savings | |
| # ═══════════════════════════════════════════ | |
| # Fetches: 19 | |
| # Data received: 669KB | |
| # Data saved: 1,004KB | |
| # Tokens saved: ~257K | |
| # Efficiency: 59% | |
| pipx install "scrapling[ai]" | |
| export PATH="$HOME/.local/bin:$PATH" # ensure pipx-installed bins are findable mid-script | |
| SCRAPLING_BIN="$(which scrapling)" | |
| # MCP: ScraplingServer (all tools) | |
| # Claude Code | |
| claude mcp add --scope user ScraplingServer "$SCRAPLING_BIN" mcp | |
| # VS Code / GitHub Copilot | |
| if [[ "$OSTYPE" == darwin* ]]; then | |
| vs="$HOME/Library/Application Support/Code/User/settings.json" | |
| else | |
| vs="$HOME/.config/Code/User/settings.json" | |
| fi | |
| mkdir -p "${vs%/*}" | |
| { [ -f "$vs" ] && cat "$vs" || echo '{}'; } | jq --arg s "$SCRAPLING_BIN" \ | |
| '.mcp.servers.ScraplingServer = {"type":"stdio","command":$s,"args":["mcp"]}' > "$vs.tmp" && mv "$vs.tmp" "$vs" | |
| # OpenCode | |
| cfg="$HOME/.config/opencode/opencode.json"; mkdir -p "${cfg%/*}" | |
| { [ -f "$cfg" ] && cat "$cfg" || echo '{}'; } | jq --arg s "$SCRAPLING_BIN" \ | |
| '.mcp.ScraplingServer = {"type":"local","command":[$s,"mcp"]}' > "$cfg.tmp" && mv "$cfg.tmp" "$cfg" | |
| # (Rust Token Killer) compresses CLI output before it hits your context window. | |
| if ! brew install rtk-ai/tap/rtk 2>/dev/null; then | |
| if ! command -v cargo >/dev/null 2>&1; then | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -a- -y --no-modify-path | |
| . "$HOME/.cargo/env" | |
| fi | |
| cargo install --git https://github.com/rtk-ai/rtk rtk | |
| fi | |
| rtk init -g # Claude Code — PreToolUse hook (bash) | |
| rtk init -g --opencode # OpenCode — TypeScript plugin (tool.execute.before) | |
| rtk init -g --copilot # VS Code / GitHub Copilot — PreToolUse hook | |
| # MCP: Context7 (all tools) | |
| # Raw pkg.go.dev page: ~50-100KB (12,000-25,000 tokens) | |
| # Context7 query result: ~1-5KB (250-1,250 tokens) | |
| # Savings per lookup: 95% | |
| # Claude Code | |
| claude mcp add context7 -- npx -y @upstash/context7-mcp@latest | |
| # VS Code / GitHub Copilot | |
| { [ -f "$vs" ] && cat "$vs" || echo '{}'; } | jq \ | |
| '.mcp.servers.context7 = {"type":"stdio","command":"npx","args":["-y","@upstash/context7-mcp@latest"]}' > "$vs.tmp" && mv "$vs.tmp" "$vs" | |
| # OpenCode — uses hosted remote endpoint, no local npx needed | |
| { [ -f "$cfg" ] && cat "$cfg" || echo '{}'; } | jq \ | |
| '.mcp.context7 = {"type":"remote","url":"https://mcp.context7.com/mcp"}' > "$cfg.tmp" && mv "$cfg.tmp" "$cfg" | |
| # | LSP Capability | Without LSP | With LSP | Token Savings | | |
| # | -------------------- | ------------------------------ | ----------------------- | ------------- | | |
| # | **Find definition** | `grep -r "func X"` → 50+ files | Exact `file:line` | ~99% | | |
| # | **Find references** | `grep -r "X("` → noisy results | All call sites, precise | ~95% | | |
| # | **Type information** | Read entire file for context | Type signature in 50ms | ~90% | | |
| # | **Rename symbol** | Search & replace (risky) | Semantic rename (safe) | ~80% | | |
| # | **Diagnostics** | Run compiler, parse errors | Instant error list | ~70% | | |
| f="$HOME/.claude/settings.json" | |
| mkdir -p "${f%/*}" | |
| { [ -f "$f" ] && cat "$f" || echo '{}'; } | jq '.env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE="50"' > "$f.tmp" && mv "$f.tmp" "$f" | |
| # Language servers | |
| ## Claude Code: enable LSP tool | |
| f="$HOME/.claude/settings.json" | |
| { [ -f "$f" ] && cat "$f" || echo '{}'; } | jq '.env.ENABLE_LSP_TOOL="1"' > "$f.tmp" && mv "$f.tmp" "$f" | |
| ## OpenCode: lsp=true enables all built-in LSP servers (Go, TS, Python, etc.) | |
| cfg="$HOME/.config/opencode/opencode.json"; mkdir -p "${cfg%/*}" | |
| { [ -f "$cfg" ] && cat "$cfg" || echo '{}'; } | jq '.lsp = true' > "$cfg.tmp" && mv "$cfg.tmp" "$cfg" | |
| ## ClaudeCode also supports any LSP server, but we'll install a few manually to demonstrate. | |
| go install golang.org/x/tools/gopls@latest | |
| if [[ "$OSTYPE" == darwin* ]]; then | |
| npm install -g pyright typescript-language-server typescript | |
| else | |
| sudo npm install -g pyright typescript-language-server typescript | |
| fi | |
| # Plugins | |
| claude plugin install gopls-lsp | |
| claude plugin install pyright-lsp | |
| claude plugin install typescript-lsp | |
| claude plugin install code-review | |
| claude plugin install superpowers | |
| claude plugin marketplace add JetBrains/go-modern-guidelines | |
| claude plugin install modern-go-guidelines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment