LanGuard: Instructions file for Claude Code

CLAUDE.md

LanGuard CLAUDE.md is an instructions file for Claude Code from roypadina/LanGuard. It costs 2,983 tokens per session, scanned C, original, MIT.

Technical instructions for LanGuard, a macOS menu-bar app that turns Wi-Fi off when a wired network connects and back on when it disconnects.

In plain words
What is it for?
Building, testing, and running LanGuard, including network-interface detection, connection monitoring, Wi-Fi control, and user notifications.
Why use it?
They describe the app's structure and handle confusing network events, such as brief connection changes while a Mac sleeps or wakes.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: mentions Claude Code.

This is roypadina/LanGuard's own configuration. It tells Claude Code how to work on LanGuard itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything LanGuard configures →

Reuse

Borrowing it

Nothing to install: this file belongs to roypadina/LanGuard. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/roypadina/LanGuard/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/roypadina/LanGuard

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for LanGuard CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/roypadina/languard/claude-md/github.svg)](https://agentmods.dev/instructions/roypadina/languard/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/roypadina/languard/claude-md"><img src="https://agentmods.dev/badge/instructions/roypadina/languard/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for LanGuard CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/roypadina/languard/claude-md"><img src="https://agentmods.dev/badge/instructions/roypadina/languard/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 2,983 This file is loaded in full into every session.
When invoked 2,983 The same file — it is already loaded in full.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.02983 $0.02983
Opus 5.5 $0.01193 $0.01193
Sonnet 5.5 $0.00597 $0.00597
Haiku 4.5 $0.00298 $0.00298

Measured 6d ago against content hash 7c7bce4b88c2, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

LanGuard CLAUDE.md scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf /Applications/LanGuard.app && ditto "$(built .app)" /Applications/LanGuard.app # replace, never merge: ditto over an old .app leaves stale files → "sealed resource is missing"; not cp -R (nests)
CLAUDE.md · 69 lines

How it starts

The opening of the file, as written. The whole thing — 69 lines — stays where its author put it; the contents beside it link to each section on GitHub.

LanGuard

macOS menu-bar app. Turns Wi-Fi off when a wired LAN link goes up, on when it goes down. Replaces the old shell com.roy.wifitoggle LaunchAgent (the app removes it on first launch).

Layout

  • LanGuard/ — app target (LanGuardApp.swift): MenuBarExtra (+ Settings… command); AppDelegate starts AppModel, shows the first-launch WelcomeWindow (didShowWelcome; skipped under LANGUARD_TEST=1, set by the UI test) and opens Settings on reopen (Finder/Raycast).
  • LanGuardPackage/Sources/LanGuardFeature/ — all logic (modular, unit-tested):
    • InterfaceCatalog — enumerate + classify Ethernet/Wi-Fi via SystemConfiguration. isVirtual(bsdName:displayName:) flags bridge/VPN/VM/tunnel adapters (pure, tested).
    • NetworkMonitor — SCDynamicStore callbacks (link/IPv4) + NSWorkspace sleep/wake; per-interface link reads (SC kSCPropNetLinkActive, ifconfig fallback). Flap guard: ignores link changes while asleep (willSleepNotification → suspended), waits a settle interval after didWakeNotification before evaluating once, and debounces callback bursts/brief flaps (1.5s). Stops a docked Mac's Ethernet dropping on sleep + returning on wake from looking like a real unplug→replug.
    • WiFiController — CoreWLAN setPower / powerOn (no sudo, no shell).
    • Notifier — UNUserNotificationCenter wrapper; banners on Wi-Fi toggle (needs OS permission, requested on launch).
    • Log — opt-in file logger. When debugLoggingEnabled (Settings → Debug) is on, appends timestamped events to ~/Library/Logs/LanGuard/languard.log (rotates at ~1MB, one backup). Log.write is a no-op while off. revealInFinder() / clear() back the Settings buttons. Instrumented across start / evaluate / edges / setWiFiPower / sleep-wake so users can capture + send a log.
    • MenuIcon — MenuState (lan/wifi/paused, pure mapping) + MenuIconStyle (icon / icon+label / label) + MenuBarLabel view used as the MenuBarExtra label.
    • ToggleEngine — edge-based decision logic, dependencies injected → testable.
    • Handover — make-before-break moves. toLAN: wait until the LAN reaches the internet (Probe, TCP to 1.1.1.1:443 scoped by requiredInterfaceType), protection.settle() with preferWiFi=false, then Wi-Fi off (kept on if protection could not leave Wi-Fi). toWiFi (menu + global HotKey, recordable HotKeyCombo): Wi-Fi on → reachable → protection.settle() with preferWiFi=true → "safe to unplug" popup. Floating ProgressPanel while it runs. Pressed again while switchedToWiFi (LAN still plugged) → AppModel.backToLAN() (reset → reconcile → engine.reapply() → toLAN).
    • Protection — connection protection: a stable per-network /32 address A on whichever link is active + routes 0.0.0.0/1,128.0.0.0/1 -ifa A, so TCP connections survive LAN↔Wi-Fi (TCP is pinned to its source IP; A moves, the IP doesn't change). Own undebounced SCDynamicStore watcher + 5 s common-mode timer; serial queue; settings captured as a main-thread Snapshot. Link-flap refresh: a State:/Network/Interface/<if>/Link change on A's interface (or another en* on the same router) marks it pending; once the link is usable again the app re-runs up (down + up = fresh /1s + alias). A 0.25 s en8 flap left A + /1s in place and Network.framework flows to hosts in use then timed out for 12 h while kernel sockets worked (2026-10-30); also once after an adopt at launch. Only on networks (router IP@MAC) where LAN+Wi-Fi shared a router (learned) or ticked by hand; user "off" → disabledNetworks, never re-learned. 30-min hold only when the guardian tore down as unhealthy; 5-min hold on verify failure / no free address.
    • NetHelper — root side (quitting LanGuard KEEPS protection: the guardian guards it, the next launch adopts it; disable/panic/uninstall remove it): Resources/languard-net.sh → /Library/PrivilegedHelperTools/languard-net (verbs up/move/adopt/down/panic/arm/check/status; exit codes mirrored in NetHelper.Exit), LaunchDaemon com.roypadina.languard-net (KeepAlive guard loop runs check every 3 s; launchd only (PPID 1); default 10 s throttle, AbandonProcessGroup so a bootout never kills a check mid-down; stamps /var/run/languard-net.tick; never back to a 3 s StartInterval: the job-respawn flood + an open Login Items settings pane panicked launchd, 2026-10-24), sudoers /etc/sudoers.d/languard = that helper path only. State-changing verbs run one at a time under lockf (/var/run/languard-net.lock, 0600; on a 15 s timeout panic/down run unlocked, others exit 75). Guardian: a vanished interface is a normal strike (iface-gone); instant teardown only on corrupt state (bad-state) — an instant undock teardown raced the app's move (2026-10-09). Health = router via A AND TCP 1.1.1.1:443 via A vs the plain address (nc -G, never -w: macOS -w is idle-only, a dead SYN waits 75 s); toWiFi checks Net.internetVia(A) before "Safe to unplug", else back to LAN (2026-10-11 office outage). attach also adds the /1s -ifscope each OTHER en* on the same router (scope_others; down → unscope): sockets bound to the still-primary dock NIC (Tailscale NE → MagicDNS 100.100.100.100) otherwise get ENETUNREACH while A is on Wi-Fi = every name lookup SERVFAIL until unplug (root cause of the 10-11/10-12 office outages; by-IP checks never see it). attach and down unscope FIRST: with a scoped and an unscoped /1 on the same iface, route get returns the scoped one (IFSCOPE) → route_if empty → verify fails (1.1.5 bug). One admin prompt (install/remove). App never arms without a fresh tick. Panic: menu → helper panic → admin fallback → inline panicOneLiner (also README + ~/Raycast-Scripts/languard-panic.sh). Safety contract in the script header; reviewed by 3 Fable gates (2026-10-06).
    • AppSettings — UserDefaults. Physical wired + Wi-Fi = opt-out (disabledWired/disabledWiFi); virtual wired = opt-in (enabledVirtual, off by default). notificationsEnabled (Wi-Fi back on), notifyMovedToLAN, switchProgressPopup, safeToUnplugPopup, hotKey, menuIconStyle, protectionEnabled, protectedNetworks/disabledNetworks, per-network stable address + holds (UserDefaults dicts).
    • LoginItem / LegacyCleanup — SMAppService login item (self-healing, see below); removes legacy LaunchAgent.
    • AppModel — wires everything; singleton AppModel.shared. setWiFiPower is idempotent — only toggles interfaces whose power actually differs and only posts the banner when something really changed.
    • Views — MenuContent (menu), ConfigView(model:pane:) (one Settings pane; virtual adapters get a "virtual" badge), About window, progress panel. SettingsWindow = AppKit NSTabViewController (toolbar tabs, per-pane height, last pane remembered) hosting one ConfigView per pane; AccessoryWindows flips the app to .regular while Settings/About/Welcome are open. WelcomeWindow also holds LaunchAtLoginToggle and SupportBox.
  • Config/ — xcconfig + entitlements. Un-sandboxed (CoreWLAN power + launchctl), ad-hoc signed, LSUIElement=YES (no Dock icon).

Read the full file on GitHub · 69 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago Changed · +45 tokens per session 7c7bce4b88c2
  2. 11d ago Changed · +118 tokens per session e3366be70347
  3. 12d ago Changed · +149 tokens per session ebbd7aeb3593
  4. 17d ago Changed · +71 tokens per session 59a860d0bedd
  5. 18d ago Changed · +2 lines · +104 tokens per session 698df8b13364
  6. 29d ago Changed · +162 tokens per session 1bffe9873a3f
  7. 1mo ago Changed · +83 tokens per session 39138210ee01
  8. 1mo ago Changed · +133 tokens per session d5824d6581ff
  9. 1mo ago Changed · +11 lines · +928 tokens per session scan A → C ac0f623d4fec
  10. 2mo ago First seen · 56 lines · 1,190 tokens per session scan A d99f57b9210d

Subscribe to this mod's changes

LanGuard CLAUDE.md is an instructions file published in the GitHub repository roypadina/LanGuard (27 stars, last pushed 6d ago), licensed MIT. It adds 2,983 tokens to every session, about $0.0119 per session on Opus 5.5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

LanGuard CLAUDE.md compared with instructions from other repositories

LanGuard CLAUDE.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
LanGuard CLAUDE.mdroypadina/LanGuardInstructions file276d agoMITC2,983Claude Code
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA5,685GitHub Copilot
langchain AGENTS.mdlangchain-ai/langchainInstructions file149ktodayMITA4,680Codex, OpenCode
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA3,093GitHub Copilot
vscode model-prompts.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA2,022GitHub Copilot