$npx -y skills add easyzoom/aix-skills --skill letter-shell-integrationUse when integrating, porting, configuring, or debugging letter-shell command shells, UART shell transport, command registration, RTOS shell tasks, or embedded debug consoles
| 1 | # letter-shell Integration |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Use this skill to integrate letter-shell as an embedded debug console safely. Prove the transport, shell task or polling loop, command registration, and authorization policy before exposing commands that modify flash, reset devices, or change production state. |
| 6 | |
| 7 | ## When To Use |
| 8 | |
| 9 | Use this skill when: |
| 10 | |
| 11 | - The user wants to add or debug letter-shell in MCU firmware. |
| 12 | - Shell input/output is missing, commands are not found, history/completion behaves wrong, or shell blocks the system. |
| 13 | - The task involves UART shell, RTT shell, RTOS shell task, command export macros, login/password, or runtime debug commands. |
| 14 | |
| 15 | Do not use this skill when the serial port itself is not trustworthy. Use `embedded-serial-log-debug` first. |
| 16 | |
| 17 | ## First Questions |
| 18 | |
| 19 | Ask for: |
| 20 | |
| 21 | - Target MCU/RTOS/compiler and letter-shell version or source. |
| 22 | - Transport backend: UART, USB CDC, RTT, TCP, or custom. |
| 23 | - Runtime model: polling loop, interrupt-driven RX, DMA RX, or RTOS task. |
| 24 | - Existing shell config, command registration method, and linker section behavior. |
| 25 | - Whether shell is allowed in production builds. |
| 26 | - Commands that may be destructive, such as erase, reset, format, calibration, network write, or firmware update. |
| 27 | |
| 28 | ## Integration Checklist |
| 29 | |
| 30 | 1. Prove transport first. |
| 31 | Confirm raw RX/TX works before debugging shell parsing. |
| 32 | |
| 33 | 1. Create one shell instance. |
| 34 | Bind it to explicit read/write functions and initialize it once. |
| 35 | |
| 36 | 1. Decide scheduling model. |
| 37 | Use a polling loop for simple bare-metal demos or a dedicated task/event-driven model for RTOS projects. |
| 38 | |
| 39 | 1. Register one harmless command. |
| 40 | Start with `version`, `help`, or `status` before adding state-changing commands. |
| 41 | |
| 42 | 1. Confirm linker retention. |
| 43 | If commands are exported through sections/macros, ensure the linker script and optimization settings keep them. |
| 44 | |
| 45 | 1. Add access control for risky commands. |
| 46 | Commands that erase flash, format filesystems, reset devices, change boot config, or modify calibration require explicit user/product approval. |
| 47 | |
| 48 | ## Porting Checks |
| 49 | |
| 50 | - UART/CDC/RTT output is non-blocking enough for the product. |
| 51 | - RX buffering handles backspace, line endings, paste bursts, and command length. |
| 52 | - Shell task stack is large enough for formatting and command handlers. |
| 53 | - Command handlers validate arguments and return useful errors. |
| 54 | - Shell does not run in interrupt context unless the library explicitly supports it. |
| 55 | - Production builds can disable or restrict debug commands. |
| 56 | |
| 57 | ## Common Failures |
| 58 | |
| 59 | - Raw UART works but shell does not receive because RX callback is not connected to shell input. |
| 60 | - Commands disappear because linker garbage collection removed command sections. |
| 61 | - Shell blocks lower-priority tasks due to long output or blocking writes. |
| 62 | - Command handler crashes from unchecked arguments. |
| 63 | - Dangerous maintenance commands are exposed without authentication or build guards. |
| 64 | |
| 65 | ## Verification |
| 66 | |
| 67 | Before claiming letter-shell works: |
| 68 | |
| 69 | - State transport, scheduler model, shell instance, and command registration method. |
| 70 | - Confirm `help` or an equivalent harmless command works. |
| 71 | - Confirm one custom read-only command works. |
| 72 | - Confirm line ending, backspace, and invalid command behavior. |
| 73 | - Identify destructive commands and their guard policy. |
| 74 | |
| 75 | ## Example |
| 76 | |
| 77 | User: |
| 78 | |
| 79 | ```text |
| 80 | 想接 letter-shell,通过串口输入命令查看系统状态。 |
| 81 | ``` |
| 82 | |
| 83 | Agent: |
| 84 | |
| 85 | 1. Asks for UART backend, RTOS/bare-metal model, config, and command export method. |
| 86 | 1. Verifies raw serial RX/TX first. |
| 87 | 1. Registers a read-only `status` command and confirms `help` can list it. |
| 88 | 1. Adds guardrails before exposing reset, erase, or format commands. |