Installs into .claude/skills of the current project.
Are you the author of Code 1.0.4?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/kairos-ai-agent-code-1-0-4)
---
name: "code-1.0.4"
description: "Coding workflow with planning, implementation, verification, and testing for clean software development."
priority: 0.5
version: "1.0.5"
imported-from: "hermes"
source-path: "hermes/skills/code-1.0.4/SKILL.md"
---
## When to Use
User explicitly requests code implementation. Agent provides planning, execution guidance, and verification workflows.
## Architecture
User preferences stored in `~/code/` when user explicitly requests.
```
~/code/
- memory.md # User-provided preferences only
```
Create on first use: `mkdir -p ~/code`
## Quick Reference
| Topic | File |
|-------|------|
| Memory setup | `memory-template.md` |
| Task breakdown | `planning.md` |
| Execution flow | `execution.md` |
| Verification | `verification.md` |
| Cloudflare Worker + B2 | `references/cloudflare-worker-b2-storage.md` |
| Cloudflare Worker deploy | `references/cloudflare-worker-spa-deploy.md` |
| Multi-file SPA pattern | `references/multi-file-spa-pattern.md` |
| Multi-task state | `state.md` |
| User criteria | `criteria.md` |
## Scope
This skill ONLY:
- Provides coding workflow guidance
- Stores preferences user explicitly provides in `~/code/`
- Reads included reference files
This skill NEVER:
- Executes code automatically
- Makes network requests
- Accesses files outside `~/code/` and the user's project
- Modifies its own SKILL.md or auxiliary files
- Takes autonomous action without user awareness
## Core Rules
### 1. Check Memory First
Read `~/code/memory.md` for user's stated preferences if it exists.
### 2. User Controls Execution
- This skill provides GUIDANCE, not autonomous execution
- User decides when to proceed to next step
- Sub-agent delegation requires user's explicit request
### 3. Plan Before Code
- Break requests into testable steps
- Each step independently verifiable
- See `planning.md` for patterns
### 4. Verify Everything
| After | Do |
|-------|-----|
| Each function | Suggest running tests |
| UI changes | Suggest taking screenshot |
| Before delivery | Suggest full test suite |
### 5. Store Preferences on Request
| User says | Action |
|-----------|--------|
| "Remember I prefer X" | Add to memory.md |
| "Never do Y again" | Add to memory.md Never section |
Only store what user explicitly asks to save.
## Workflow
```
Request -> Plan -> Execute -> Verify -> Deliver
```
## Common Traps
- **``***`` content corruption in tool calls** — When writing code (via patch(), write_file(), or execute_code()) that contains the string-concatenation pattern ``'Bearer ' + token`` (or any ``QUOTE`` + ``VARIABLE`` sequence involving a closing quote followed by `` + ``), the system content pipeline may corrupt it by injecting literal ``***`` characters, turning your string into ``'Bearer *** + token``. This breaks the syntax. Workarounds:
1. **terminal() with heredoc** — write files via ``cat > file << 'PYEOF'`` (single-quoted delimiter prevents bash expansion) to bypass the content pipeline entirely.
2. **execute_code with variable indirection** — store the concatenation prefix in a variable first (``prefix_str = "Bearer "`` then ``auth_val = f"{prefix_str}{token}"``) instead of writing ``'Bearer ' + token`` inline.
3. **Post-write fix** — write the file with a placeholder (e.g. ``AUTH_PLACEHOLDER``), then use terminal() ``sed`` or Python ``.replace()`` to swap it in after the file is on disk.
4. **base64 hex encoding** — For particularly stubborn cases, encode the whole file as base64 in your message, then decode on disk.
This trap affects any on-the-fly code writing that builds auth headers, Bearer tokens, or any ``' + variable`` pattern.
- **Delivering untested code** -> always verify first
- **Self-verify before reporting** — When the user says "做了发我" or "你看看", do NOT deliver immediately. First: (1) check browser_console for JS errors, (2) click-test interactive features, (3) `curl` the deployed endpoint to confirm 200 response, (4) verify the DOM renders expected content via browser_snapshot. Only report "done" after YOU have confirmed it works. A buggy deliverable wastes user time and erodes trust.
- **SPA JS syntax validation via `node --check`** — When editing a single-file SPA (JS embedded in HTML `<script>` tags), the browser often reports empty/invisible errors. Extract each `<script>` block with `re.findall(r'<script[^>]*>(.*?)</script>', html, re.DOTALL)`, write to a temp `.js` file, and run `node --check temp.js`. This catches syntax errors (unclosed backticks, stray tokens, duplicate lines) that the browser swallows. For large script blocks (>50K), binary-search the error range with `new Function(t.substring(mid))` try-catch.
- **Backtick counting detects unclosed template literals** — In a JS array of template-literal bodies (`b:\`...\`\`), odd backtick count = one is unclosed. Count with `for(;;){if(t[i]==='`')count++}`. Each article pair contributes 2 backticks. A count of 249 instead of 240 (for 120 articles) means 9 stray backticks or an unclosed one — find the article with odd count by splitting on `{id:` and checking each fragment.
- **Markdown code-fence backticks inside a JS template literal silently kill the entire `<script>` block** — A `const SYSTEM_PROMPT = \`...\`` template containing markdown like `\`\`\`json` or `\`\`\`` closes the template literal mid-string, leaving the rest of the file as bare tokens. JavaScript parses this as a syntax error and the **entire inline `<script>` block is silently skipped by the browser** — no console error shown in some cases, page just stays on initial state forever. Detect by running `node --check temp.js` on the extracted block. Two fixes: (1) describe the fence in plain Chinese instead of literal backticks (`"不要用三反引号+json+三反引号 这种包裹"`), or (2) escape with `\`` if the literal is unavoidable. Same trap fires for code examples inside system prompts, regex literals inside templates, or nested template literals.
- **HTML-with-backtick-in-Worker: use base64** — When deploying an HTML SPA via Cloudflare Worker, wrapping the entire HTML in a JS template literal (`const html = \`...\``) breaks because the HTML contains backtick characters (from article template-literal bodies like `b:\`...\``). Fix: base64-encode the HTML in Python (`base64.b64encode(html_bytes)`), embed the base64 string in the Worker, then decode with `Uint8Array` + `TextDecoder`:
```js
const binary = atob(b64);
const bytes = new Uint8Array(binary.length);
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
const html = new TextDecoder().decode(bytes);
```
This avoids all escaping conflicts with backticks, `${`, and other JS template-literal special characters.
- **Huge PRs** -> break into testable chunks
- **Ignoring preferences** -> check memory.md first
- **Whole-file rewrite when a surgical edit was needed** — When a task is a simple visual change (swap an icon, change a color, edit text), use patch() on the specific elements that need changing. Never write_file() the whole file — it destroys formatting, changes DOM structure JS depends on, breaks element IDs/class bindings, and introduces regressions the user never asked for. Only write the full file when the task IS "restructure this entire page" or "create a new file from scratch".
- **Before editing HTML, map all JS dependencies** — Survey what IDs, classes, and script tags the JS queries (getElementById, querySelector). Make a checklist. Verify every single reference still resolves after your edit. Missing a `<script>` tag (like home_styles.js) silently breaks entire features (style dropdown, etc.) with no obvious error message.
- **Always read the ENTIRE file before modifying** — Use read_file with no offset/limit to get the complete picture. A partial read misses critical structure, IDs, and script references that you'll destroy on write_file or mismatch in patch(). If the file is over 2000 lines, use multiple paginated reads to cover all sections.
- **After any edit, check the console** — For web pages, navigate in browser and check browser_console for JS errors (empty-message exceptions, missing-element errors, unhandled rejections). A page that "looks right" can have broken JS that user won't notice until they click something.
- **Restoring from `.bak`: verify completeness first** — A `.bak` file can be significantly shorter than the original (e.g. 484 lines vs 1062). Before `cp`-ing a `.bak` over your working file, run `wc -l` on both and confirm they're in the same ballpark. Restoring from an incomplete .bak destroys the working page and forces a full rewrite from scratch. Always create your OWN backup before modifying: `cp file.html file.html.YYYYMMDD_HHMMSS.bak`.
- **Multi-line SVG/HTML patching: use surrounding text anchors** — When replacing multi-line SVG blocks (6+ lines of `<rect>`, `<path>`, `<circle>`), don't include the full SVG content in `patch(old_string=...)`. Instead, use unique surrounding context like `</svg>\n <span class="label">图生图</span>` or the button's `data-mode` attribute. SVG content is fragile — a single indentation mismatch or path attribute breaks the match. Safer: match from the `<svg` tag through to the closing `</svg>` using unique button text as the outer boundary.
- **Server restart: verify old processes are dead** — After editing `server.js`, run `netstat -ano | grep LISTENING | grep :PORT` to find the old PID, then `taskkill //F //PID X`. A stale node process (started before your edit) keeps the old code in memory. The `background` task may exit with EADDRINUSE silently — check `process(action='poll')` after start, or verify with `curl` before assuming the new code is live.
- **`write_file` on an existing file is a full rewrite** — Only use `write_file` when creating a new file or when the task IS a full-page restructuring. For any targeted visual change (swap an icon, change a color, edit one button), use `patch()`. `write_file` destroys formatting, CSS structure, element hierarchy, and JS bindings — the cost of reconstructing what you broke is always higher than doing a precise patch.
- **Clarify ambiguous natural-language requests before taking destructive action** — Chinese comma-separated lists like "文生图 图生图,不需要音频,删除" could mean "remove audio from modes A and B" NOT "remove mode B entirely". When the user lists items followed by an action, confirm WHICH items the action applies to before deleting anything structural. A clarification check costs one turn; restoring a deleted mode costs many.
- **After any HTML edit, click-test every interactive feature** — A page with 0 console errors can still have broken interactivity (missing event listeners, unloaded script modules, incorrect data attributes). After the console check, click each button/dropdown/toggle and verify it responds. Silent breaks like "style dropdown doesn't open" are caused by missing `<script>` tags or module load failures that don't produce console errors.
## Self-Modification
This skill NEVER modifies its own SKILL.md or auxiliary files.
User data stored only in `~/code/memory.md` after explicit request.
## External Endpoints
This skill makes NO network requests.
| Endpoint | Data Sent | Purpose |
|----------|-----------|---------|
| None | None | N/A |
## Security & Privacy
**Data that stays local:**
- Only preferences user explicitly asks to save
- Stored in `~/code/memory.md`
**Data that leaves your machine:**
- None. This skill makes no network requests.
**This skill does NOT:**
- Execute code automatically
- Access network or external services
- Access files outside `~/code/` and user's project
- Take autonomous actions without user awareness
- Delegate to sub-agents without user's explicit request