Skip to content

Instantly share code, notes, and snippets.

View wong2's full-sized avatar
๐Ÿƒ
Waiting for autumn

wong2 wong2

๐Ÿƒ
Waiting for autumn
View GitHub Profile
@wong2
wong2 / claude-code-tools.md
Last active June 14, 2025 02:23
Tools and system prompt of Claude Code

Task

Launch a new agent that has access to the following tools: Bash, Glob, Grep, LS, exit_plan_mode, Read, Edit, MultiEdit, Write, NotebookRead, NotebookEdit, WebFetch, TodoRead, TodoWrite, WebSearch. When you are searching for a keyword or file and are not confident that you will find the right match in the first few tries, use the Agent tool to perform the search for you.

When to use the Agent tool:

  • If you are searching for a keyword like "config" or "logger", or for questions like "which file does X?", the Agent tool is strongly recommended

When NOT to use the Agent tool:

  • If you want to read a specific file path, use the Read or Glob tool instead of the Agent tool, to find the match more quickly
  • If you are searching for a specific class definition like "class Foo", use the Glob tool instead, to find the match more quickly
  • If you are searching for code within a specific file or set of 2-3 files, use the Read tool instead of the Agent tool, to find the match more quickly
@wong2
wong2 / README.md
Last active January 12, 2025 03:12
How to run Claude computer use demo on macOS

Note

It is necessary to give Terminal (or iTerm or whatever you use) the permission to control the computer. This can be done in System Settings โž” Privacy & Security โž” Accessibility.

Guide

  • Install cliclick for mouse & keyboard emulation
    • brew install cliclick
  • Clone Anthropic quickstart repo
    • git clone https://github.com/anthropics/anthropic-quickstarts.git
  • cd computer-use-demo
  • Replace computer-use-demo/computer_use_demo/tools/computer.py with the modified version below
from io import BytesIO
import torch
from fastapi.responses import StreamingResponse
from leptonai.photon import Photon
from loguru import logger
class JPEGResponse(StreamingResponse):
media_type = "image/jpeg"
async function* streamAsyncIterable<T = unknown>(stream: ReadableStream<T>) {
const reader = stream.getReader()
try {
while (true) {
const { done, value } = await reader.read()
if (done) {
return
}
yield value
}
import { Chain, Common } from "@nomicfoundation/ethereumjs-common";
import { TransactionFactory } from "@nomicfoundation/ethereumjs-tx";
import { VM } from "@nomicfoundation/ethereumjs-vm";
import { ForkBlockchain } from "hardhat/internal/hardhat-network/provider/fork/ForkBlockchain";
import { ForkStateManager } from "hardhat/internal/hardhat-network/provider/fork/ForkStateManager";
import { makeForkClient } from "hardhat/internal/hardhat-network/provider/utils/makeForkClient";
const JSON_RPC_URL = "https://rpc.ankr.com/eth";
async function simulateTx(signedTx: string) {
@wong2
wong2 / SocialRecoveryAccount.sol
Last active August 26, 2022 04:00
Minimum social recovery wallet implementation on zkSync https://vitalik.ca/general/2021/01/11/recovery.html
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@matterlabs/zksync-contracts/l2/system-contracts/interfaces/IAccountAbstraction.sol";
import "@matterlabs/zksync-contracts/l2/system-contracts/TransactionHelper.sol";
import "@matterlabs/zksync-contracts/l2/system-contracts/Constants.sol";
import "@openzeppelin/contracts/interfaces/IERC1271.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import HDWalletProvider from "@truffle/hdwallet-provider";
import { OpenSeaPort, Network } from "opensea-js";
import { PRIVATE_KEY } from "./consts.mjs";
const provider = new HDWalletProvider({
privateKeys: [PRIVATE_KEY],
providerOrUrl: "https://rpc.ankr.com/eth",
});
provider.engine.on("error", (err) => {
{
"contracts": {
"@openzeppelin/contracts/access/Ownable.sol": {
"Ownable": {
"storageLayout": {
"storage": [
{
"astId": 7,
"contract": "@openzeppelin/contracts/access/Ownable.sol:Ownable",
"label": "_owner",

How to build MetaMask extension with Snaps enabled

  1. Clone the source code from https://github.com/MetaMask/metamask-extension
  2. Switch to snaps branch
  3. yarn setup
  4. Copy the .metamaskrc.dist file to .metamaskrc and replace the INFURA_PROJECT_ID value with your own.
  5. yarn run build prod --build-type flask
  6. The build should be located at directory dist.
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})
function jsonResponse(o) {
return new Response(JSON.stringify(o), {
headers: {
"content-type": "application/json;charset=UTF-8",
'Access-Control-Allow-Origin': '*',
}