nport
CLAUDE.md769 starsChanged 8 months agoMITView on GitHub
See also .claude/rules/ for detailed per-topic rules (TypeScript style, patterns, common tasks, project overview). NPort is a free, open-source ngrok alternative that creates secure HTTP/HTTPS tunnels from localhost to public URLs using Cloudflare's global edge network. It has three components: Traffic flow: Browser → myapp.nport.link → Cloudflare Edge → cloudflared → localhost:port CI uses npm ci --ignore-scripts for the CLI to skip cloudflared download.
- Installs packages
In this repositoryOne other file it gives its agents.
- ui-ux-pro-maxSkill
The file
We split this CLAUDE.md into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 48
ESM throughout: Always use .js extension in relative imports (this is required, not optional)
- Very specific: line 49
Type imports: Always use import type { ...
- Very specific: line 52
Prefer interface for object shapes, type for unions/aliases
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md 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.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
See also .claude/rules/ for detailed per-topic rules (TypeScript style, patterns, common tasks, project overview).
Project Overview
NPort is a free, open-source ngrok alternative that creates secure HTTP/HTTPS tunnels from localhost to public URLs using Cloudflare's global edge network. It has three components:
- CLI (
src/) — TypeScript command-line tool bundled via esbuild - Backend (
server/) — Cloudflare Worker that manages tunnel lifecycle (creates/deletes tunnels + DNS via Cloudflare APIs) - cloudflared binary (
bin/) — Downloaded at install/first-run; handles the actual tunnel connection
Traffic flow: Browser → myapp.nport.link → Cloudflare Edge → cloudflared → localhost:port
Commands
CLI (root directory)
npm install # Installs deps + downloads cloudflared (postinstall hook)
npm run build # esbuild → dist/index.js
npm run dev # esbuild --watch (fast, no minification)
npm start # node dist/index.js
npm test # vitest run (tests/**/*.test.ts)
npm run test:watch # vitest --watch
npm run lint # tsc --noEmitServer (server/ directory)
cd server
npm install
npm run dev # wrangler dev (local CF Workers preview)
npm run deploy # wrangler deploy
npm test # vitest run
npm run typecheck # tsc --noEmitTypeScript Conventions
- ESM throughout: Always use
.jsextension in relative imports (this is required, not optional) - Type imports: Always use
import type { ... }for type-only imports - Import order: external packages → internal modules → types
strict: true— full type safety; avoidany- Prefer
interfacefor object shapes,typefor unions/aliases
// ✅ Correct
import axios from 'axios';
import { CONFIG } from './config.js';
import type { TunnelConfig } from './types/index.js';
// ❌ Wrong — no .js extension, uses `any`
import { something } from './module';
function process(data: any) { ... }Key Modules
| File | Responsibility |
src/tunnel.ts | TunnelOrchestrator.start() / cleanup() — orchestrates entire tunnel lifecycle |
src/api.ts | APIClient — POST create / DELETE delete against backend |
src/binary.ts | BinaryManager — validates, spawns, and handles cloudflared stdout/stderr |
src/bin-manager.ts | ensureCloudflared() — downloads cloudflared from GitHub (platform-specific) |
src/state.ts | TunnelState singleton — runtime state (tunnelId, subdomain, port, process) |
src/config-manager.ts | ConfigManager singleton — persists ~/.nport/config.json |
src/analytics.ts | AnalyticsManager singleton — GA4 Measurement Protocol |
server/src/index.ts | CF Worker fetch handler + scheduled cleanup (every 30 min) |
Configuration Priority (Backend URL)
- CLI flag
--backend/-b - Saved config
~/.nport/config.jsonvia--set-backend - Environment variable
NPORT_BACKEND_URL - Default
https://api.nport.link
Environment Variables
| Variable | Effect |
NPORT_BACKEND_URL | Override backend URL |
NPORT_ANALYTICS=false | Disable GA4 tracking |
NPORT_DEBUG=true | Enable analytics debug logs |
CI Pipelines
| Workflow | Trigger | What it does |
ci.yml | push/PR to main | Type-check + test CLI; type-check + test server |
deploy-server.yml | push to server/** | Deploy CF Worker via wrangler-action |
deploy-website.yml | push to website/** | Deploy to Cloudflare Pages |
release-npm.yml | GitHub release | Build + npm publish |
CI uses npm ci --ignore-scripts for the CLI to skip cloudflared download.
Adding a New Language
src/constants.ts→AVAILABLE_LANGUAGES— add language codesrc/types/i18n.ts→LanguageCode— add union typesrc/lang.ts→TRANSLATIONS— add translation objectnpm run build
Adding a CLI Flag
src/args.ts→ArgumentParser— add parsing methodsrc/types/config.ts→ParsedArguments— add fieldsrc/index.ts→main()— handle the flagtests/→ add unit tests
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
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.

