Prefilling Device Specific Code
YAML--- name: prefilling-device-specific-code description: Automatically incorporates the user's known device, network, and environment details (IP addresses, hostnames, SSH configs, OS/platform specifics, credentials placeholders, etc.) into any code, scripts, or configuration Claude generates or revises, delivering ready-to-run copy-paste output instead of generic templates. Use when writing or updating scripts, code, or connection configs that involve the user's specific devices, servers, networks, or operating systems. ---
Before generating any script/code touching a device, connection, or OS-specific setting, check the maintained Device Profile (see below). Fill in real values instead of placeholders.
Instead of:
Bashssh user@<host> -p <port>
Output:
Bashssh admin@192.168.1.42 -p 2222
If a required value isn't yet known, ask once, then store it in the Device Profile for all future use.
Maintain a running profile of the user's environment. Populate incrementally — never re-ask for info already given. Suggested structure:
DEVICE PROFILE
- Devices: [name, OS, role] e.g. "Home-Server: Ubuntu 22.04, hosts Plex + SSH"
- Network: [LAN subnet, static IPs, router IP, DNS]
- SSH: [user, host, port, key path/auth method per device]
- Cloud/Remote: [provider, instance IDs, regions, endpoints]
- Preferred tools/stacks: [languages, frameworks, shells]
- Credential handling: [env vars / secrets manager — never hardcode real passwords/keys]
Store this in a persistent note/memory file (e.g., DEVICE_PROFILE.md in the project or Claude's memory) and update it whenever the user shares new device/network info.
Progress:
- Identify if the request involves a specific device, network, connection, or OS
- Check Device Profile for matching known values
- If missing critical values, ask concisely (batch questions, ask once)
- Update Device Profile with any new info provided
- Generate/revise code with real values pre-filled
- Output as a single complete, copy-paste-ready block
- Flag any placeholder that couldn't be filled (e.g., secrets) and explain how to supply it securely
Example 1: Input: "Update this script to connect to my NAS." Output:
Bash#!/bin/bash # Connects to Synology NAS (per Device Profile) ssh -i ~/.ssh/nas_key admin@10.0.0.15 "df -h"
(No placeholders — uses stored IP, user, and key path.)
Example 2: Input: "Give me a Python script to ping my home server and Raspberry Pi." Output:
Pythonimport subprocess devices = { "Home-Server": "192.168.1.10", "RaspberryPi": "192.168.1.20", } for name, ip in devices.items(): result = subprocess.run(["ping", "-c", "1", ip], capture_output=True, text=True) status = "UP" if result.returncode == 0 else "DOWN" print(f"{name} ({ip}): {status}")
Example 3:
Input: "I just switched from Windows to macOS."
Output: Update Device Profile OS field; regenerate any prior scripts that had OS-specific syntax (e.g., swap ipconfig → ifconfig/ networksetup, path separators, package manager commands) using the new OS automatically in future outputs.
- Always output the full revised file/script, not a diff, unless the user asks for a diff — ready to copy-paste.
- Never hardcode real passwords or private keys in plaintext code; use env vars,
.envfiles, or secret managers, but DO pre-fill non-secret identifiers (IPs, ports, usernames, hostnames). - When device details might have changed (e.g., dynamic IP), note it and suggest a quick way to verify (e.g., "confirm this is still your IP").
- Keep the Device Profile in one canonical place; reference it, don't duplicate scattered copies.
- When multiple devices could match a request, ask which one instead of guessing.
- Don't leave
<placeholder>orTODOvalues when the real value is already known. - Don't ask for the same device info repeatedly across sessions — persist it.
- Don't silently invent IPs/hostnames if unknown — ask instead of fabricating.
- Don't embed real secrets (passwords, private keys, tokens) directly in shared/generated code.