Skip to content

Instantly share code, notes, and snippets.

flowchart TD
    %% Main Entry Point and Initialization
    Start([Application Start]) --> ParseArgs[Parse Command Line Arguments]
    ParseArgs --> CheckStdin{Check stdin}
    CheckStdin -->|Input Piped| ProcessPiped[Process Piped Input]
    CheckStdin -->|Interactive Mode| CheckAuth{Authentication Status}
    
    %% Authentication Flow
    CheckAuth -->|Not Authenticated| OAuthFlow[OAuth Authentication]
@leehanchung
leehanchung / test.py
Created March 8, 2025 23:40
testing aws bedrock seetup for claude code
import boto3
import json
client = boto3.client('bedrock-runtime', region_name='us-east-1')
response = client.invoke_model(
modelId='us.anthropic.claude-3-7-sonnet-2025-0219-v1:0',
body=json.dumps({
"anthropic_version": "bedrock-2023-05-31",
"messages": [
@leehanchung
leehanchung / claude_code_csp.mjs
Created March 8, 2025 23:14
claude code using aws vertexai
var c9 = !!process.env.CLAUDE_CODE_USE_BEDROCK,
p9 = !!process.env.CLAUDE_CODE_USE_VERTEX,
Tl1 = {
bedrock: 'us.anthropic.claude-3-7-sonnet-20250219-v1:0',
vertex: 'claude-3-7-sonnet@20250219',
firstParty: 'claude-3-7-sonnet-20250219',
},
PB = c9
? 'us.anthropic.claude-3-5-haiku-20241022-v1:0'
: p9
@leehanchung
leehanchung / claude_code_mcp.mjs
Last active March 8, 2025 09:08
claude code mcp implementation
async function OX9(I, G) {
let Z =
G.type === 'sse'
? new jN1(new URL(G.url))
: new MN1({
command: G.command,
args: G.args,
env: { ...process.env, ...G.env },
stderr: 'pipe',
}),
@leehanchung
leehanchung / scratchpad.mjs
Created March 8, 2025 08:42
claude code thinking scratchpad
async function Lu(I) {
if (await ug.isEnabled())
return (
s1('tengu_thinking', {
method: 'scratchpad',
tokenCount: '0',
messageId: QZ(I),
provider: c9 ? 'bedrock' : p9 ? 'vertex' : '1p',
}),
0
@leehanchung
leehanchung / system_prompts.mjs
Created March 8, 2025 08:33
claude code system prompts
function CQ2() {
return `You are ${w4}, Anthropic's official CLI for Claude.`
}
async function fR() {
return [
`You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
IMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.
IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).
@leehanchung
leehanchung / cli_ocaml.mjs
Created March 8, 2025 08:26
claude code ocaml syntax parsing
var FD2 = _((AQ3, HD2) => {
function M99(I) {
return {
name: 'OCaml',
aliases: ['ml'],
keywords: {
$pattern: '[a-z_]\\w*!?',
keyword:
'and as assert asr begin class constraint do done downto else end exception external for fun function functor if in include inherit! inherit initializer land lazy let lor lsl lsr lxor match method!|10 method mod module mutable new object of open! open or private rec sig struct then to try type val! val virtual when while with parser value',
built_in:
@leehanchung
leehanchung / easter_egg.mjs
Created March 8, 2025 08:07
claude code sticker easter egg
var SE2 = 'Sends the user swag stickers with love from Anthropic.',
LE2 = `This tool should be used whenever a user expresses interest in receiving Anthropic or Claude stickers, swag, or merchandise. When triggered, it will display a shipping form for the user to enter their mailing address and contact details. Once submitted, Anthropic will process the request and ship stickers to the provided address.
Common trigger phrases to watch for:
- "Can I get some Anthropic stickers please?"
- "How do I get Anthropic swag?"
- "I'd love some Claude stickers"
- "Where can I get merchandise?"
- Any mention of wanting stickers or swag
@leehanchung
leehanchung / cli.mjs
Last active March 17, 2025 14:18
formatted claude code cli.mjs
This file has been truncated, but you can view the full file.
#!/usr/bin/env -S node --no-warnings=ExperimentalWarning --enable-source-maps
// Claude Code is a Beta product per Anthropic's Commercial Terms of Service.
// By using Claude Code, you agree that all code acceptance or rejection decisions you make,
// and the associated conversations in context, constitute Feedback under Anthropic's Commercial Terms,
// and may be used to improve Anthropic's products, including training models.
// You are responsible for reviewing any code suggestions before use.
// (c) Anthropic PBC. All rights reserved. Use is subject to Anthropic's Commercial Terms of Service (https://www.anthropic.com/legal/commercial-terms).
@leehanchung
leehanchung / .pre-commit-config.yaml
Created July 18, 2024 16:43
sample python pre-commit configuration
fail_fast: true
default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace