agentleFS
AirMileAirMile/claude-config/skills/project-tunnel/SKILL.md

project-tunnel

Skill0 starsChanged 4 months agoMITView on GitHub

Expose local dev server via Cloudflare Tunnel. Use with /project-tunnel.

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 7 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Start the dev server with Cloudflare Tunnel for HTTPS access from any device.

    line 12
  2. Very specific:

    Dependencies: If node_modules does not exist → run npm install first.

    line 33
  3. Very specific:

    Vite allowedHosts: If Vite project, check whether vite.config has a server.allowedHosts that allows .trycloudflare.com.

    line 35
  4. Very specific:

    Port 3000: Use curl to detect whether a server is already running:

    line 43
  5. Very specific:

    Wait until the server is ready using curl (max 20s, first compile can take a while):

    line 84
  6. Very specific:

    Not ready after 20s → show last 20 lines from /tmp/devserver.log and stop.

    line 94
  7. Distinctive:

    Check for existing tunnel first:

    line 100
  8. Distinctive:

    No active tunnel → start a new one:

    line 106
  9. Distinctive:

    After obtaining the tunnel URL in step 4:

    line 127
  10. Very specific:

    Check whether next.config already has an allowedDevOrigins array with this hostname

    line 130
  11. Very specific:

    If not → replace the entire allowedDevOrigins array with only the new hostname (old tunnel hostnames are invalid anyway)

    line 131
  12. Distinctive:

    Verify that the server is still running after auto-restart:

    line 133
  13. Distinctive:

    If the server does NOT respond after 15s → restart manually (see step 3)

    line 144
  14. Distinctive:

    Verify again with curl loop, report tunnel URL

    line 145

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Project Tunnel

Start the dev server with Cloudflare Tunnel for HTTPS access from any device.

1. Detect framework

Check package.json dependencies:

  • "vite" → Vite project
  • "next" → Next.js project
  • Otherwise → error: "No supported framework found in package.json"

Start commands:

FrameworkCommand
Vitenode node_modules/.bin/vite --port 3000 --host
Next.jsnode node_modules/.bin/next dev -p 3000

Important: Always use node node_modules/.bin/... instead of npx. npx wrapper processes sometimes die silently under nohup, while direct node invocation is stable.

2. Pre-flight checks

Dependencies: If node_modules does not exist → run npm install first.

Vite allowedHosts: If Vite project, check whether vite.config has a server.allowedHosts that allows .trycloudflare.com. If not → add:

server: {
  allowedHosts: [".trycloudflare.com"];
}

Port 3000: Use curl to detect whether a server is already running:

curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:3000
  • 200/3xx → something is running. Check /tmp/devserver.log for the project path.
    • Same project → skip to step 4
    • Different project → report which project, kill everything (step 2b), continue to step 3
  • 000 (no connection) → free, continue to step 3

2b. Cleanup (when kill is needed)

Kill in three layers to prevent zombie processes:

# Layer 1: port-based
fuser -k 3000/tcp 2>/dev/null

# Layer 2: framework processes (use what applies)
# Next.js:
pkill -f "next dev" 2>/dev/null
pkill -f "next-router-worker" 2>/dev/null
# Vite:
pkill -f "vite" 2>/dev/null

# Layer 3: tunnel
pkill -f cloudflared 2>/dev/null

sleep 2

fuser and ss sometimes fail to detect Node.js dev servers because the port is bound in a way that is not visible to these tools. Therefore always also use pkill -f with the framework-specific process name.

3. Start dev server

nohup [framework command] > /tmp/devserver.log 2>&1 &
echo $! > /tmp/devserver.pid

Wait until the server is ready using curl (max 20s, first compile can take a while):

for i in $(seq 1 20); do
  HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:3000 2>/dev/null)
  [ "$HTTP_CODE" = "200" ] && echo "ready" && break
  sleep 1
done

Not ready after 20s → show last 20 lines from /tmp/devserver.log and stop.

Verification: Always use curl against 127.0.0.1:3000, never ss or lsof. These tools do not reliably detect Node.js dev servers.

4. Start tunnel

Check for existing tunnel first:

pgrep -f cloudflared > /dev/null && grep -oE 'https://[a-z0-9-]+\.trycloudflare\.com' /tmp/cloudflared.log 2>/dev/null | head -1

No active tunnel → start a new one:

pkill -f cloudflared 2>/dev/null; sleep 1
nohup cloudflared tunnel --url http://localhost:3000 --config /dev/null --metrics 127.0.0.1:0 > /tmp/cloudflared.log 2>&1 &
sleep 10
grep -oE 'https://[a-z0-9-]+\.trycloudflare\.com' /tmp/cloudflared.log | head -1

--config /dev/null prevents a named tunnel config (~/.cloudflared/config.yml) from breaking the quick tunnel. --metrics 127.0.0.1:0 prevents metrics port conflicts.

Report the tunnel URL.

5. Framework-specific tunnel config

Next.js: allowedDevOrigins

Next.js blocks cross-origin requests from unknown origins in dev mode. Without the tunnel hostname in allowedDevOrigins, client components do not hydrate (page stays stuck on loading state).

Important: Next.js does NOT support wildcard subdomain matching (.trycloudflare.com does not work). The full tunnel hostname is required.

After obtaining the tunnel URL in step 4:

  1. Extract the hostname from the tunnel URL (without https://)
  2. Check whether next.config already has an allowedDevOrigins array with this hostname
  3. If not → replace the entire allowedDevOrigins array with only the new hostname (old tunnel hostnames are invalid anyway)
  4. Wait 5 seconds — Next.js detects config changes and restarts automatically
  5. Verify that the server is still running after auto-restart:
sleep 5
for i in $(seq 1 15); do
  HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:3000 2>/dev/null)
  [ "$HTTP_CODE" = "200" ] && echo "ready" && break
  sleep 1
done
  1. If the server does NOT respond after 15s → restart manually (see step 3)
  2. Verify again with curl loop, report tunnel URL

Because quick tunnels get a random hostname on each start, this step must be executed every time.

Vite: no action needed

Vite has no origin restriction in dev mode. After step 4 report the tunnel URL directly.

Stop

On request to stop:

fuser -k 3000/tcp 2>/dev/null
# Kill framework processes (use what applies)
pkill -f "next dev" 2>/dev/null
pkill -f "next-router-worker" 2>/dev/null
pkill -f "vite" 2>/dev/null
# Kill tunnel
pkill -f cloudflared 2>/dev/null

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.