Mẫu sử dụng và hướng dẫn prompting¶
local-shell-mcp cung cấp tools mạnh. Kết quả tốt phụ thuộc vào việc yêu cầu model kiểm tra trước, hành động theo bước nhỏ, chạy xác minh và báo cáo thay đổi.
Vòng vận hành chung¶
Dùng vòng này cho phần lớn coding task:
- Inspect:
environment_get,file_tree,file_grep,file_readvàrun_shellcho command nhưgit status. - Plan: yêu cầu model xác định tối thiểu files và tests liên quan.
- Edit: dùng
file_edit,file_patchhoặc shell commands. - Verify: chạy targeted tests/builds bằng
run_shellhoặc persistent shells. - Review: chạy
git diffquarun_shell, sau đó dùngsecret_scanvàaudit_tailkhi cần. - Commit/export: dùng explicit Git CLI commands qua
run_shellhoặclink_create.
Chọn tool¶
| Task | Ưu tiên | Tránh |
|---|---|---|
| One-shot command ngắn | run_shell |
Khởi động persistent shell cho mọi command |
| Dev server, REPL hoặc watch task dài | shell_start + shell_read + shell_send |
Block run_shell đến timeout |
| Structured analysis hoặc file generation | run_python |
Shell pipeline mong manh cho JSON/text phức tạp |
| Edit exact nhỏ | file_edit |
Viết lại cả file không cần thiết |
| Một hoặc nhiều replacement trong một file | file_edit with an edits array |
Lặp stale edit mà không đọc lại |
| Multi-file patch | file_patch |
Ad hoc shell edit |
| Tìm file | file_tree, file_glob |
Recursive listing toàn bộ repository lớn |
| Tìm code | file_grep |
Đọc nhiều file không định hướng |
| Browser evidence | browser_snapshot, browser_run_script |
Đoán từ tên page/route |
| Downloadable artifacts | link_create |
Dán binary content lớn vào chat |
| Remote machine work | normal tools with machine, plus remote_transfer |
Mở inbound SSH khi outbound worker đã đủ |
Template prompt¶
Read-only repository orientation¶
Dùng local-shell-mcp. Kiểm tra layout repository và git status. Không sửa file. Tóm tắt các component chính, test command có thể suy ra và risk rõ ràng trước khi thay đổi.
Focused bug fix¶
Dùng local-shell-mcp để sửa bug. Trước hết reproduce hoặc locate bằng relevant command nhỏ nhất. Đọc file trước khi edit. Tạo minimal patch, chạy targeted verification, sau đó hiển thị git diff và chính xác các tests đã chạy. Không commit cho tới khi tôi chấp thuận.
Workflow commit và push¶
Dùng local-shell-mcp. Kiểm tra git status và diff, chạy relevant tests và secret_scan, tạo một focused commit với message ngắn, rồi push current branch. Không bao gồm cache, build artifacts hoặc unrelated formatting.
Long-running process¶
Khởi động dev server trong persistent shell session, đọc output đến khi ready, rồi dùng browser tools để xác minh page. Giữ session id và kill session sau khi xác minh.
Remote worker task¶
Dùng remote worker đã kết nối tên <machine>. Trước tiên gọi environment_get với machine=<machine>, sau đó file_list với cùng machine. Chỉ làm việc trong configured remote workdir. Dùng run_shell cho command ngắn và shell_start hoặc job_start cho công việc dài.
Làm việc với repositories¶
Sequence khuyến nghị cho thay đổi open-source:
- Chạy
git status --short --branchquarun_shell. - Fetch và inspect branches bằng explicit Git CLI khi upstream state quan trọng.
- Dùng
file_grepvàfile_readtrước edit. - Tạo minimal patch.
- Chạy targeted tests trước, rồi broader tests khi phù hợp.
- Chạy
secret_scantrước commit hoặc push. - Stage và commit rõ ràng với message ngắn.
Yêu cầu một commit cho mỗi logical change khi maintainer cần history dễ review.
Làm việc với generated artifacts¶
Với PDF, report, screenshot, archive hoặc log:
- Generate file trong workspace.
- Xác minh file tồn tại và có size đúng.
- Dùng
link_createvới TTL ngắn và optionalmax_downloads. - Revoke link khi không còn cần.
Không tạo public link cho private key, credential directory hoặc unrelated personal data.
Làm việc với remote machines¶
Remote worker mode hữu ích khi machine có thể gửi outbound HTTPS nhưng không nhận inbound SSH.
Thực hành tốt:
- Tạo hoặc rename machine bằng
remote_manage(action="invite", ...)hoặcremote_manage(action="rename", ...). - Gọi
environment_get(machine=...)trước khi hành động. - Dùng
remote_transferđể khởi động controller/worker hoặc worker/worker transfer jobs rồi quản lý bằng normaljob_*tools. - Revoke worker sau task bằng
remote_manage(action="revoke", ...).
Anti-patterns¶
Tránh các chỉ dẫn sau trừ khi environment disposable và đã hiểu hậu quả:
- “Install global bất cứ thứ gì cần” trên host-launched server.
- “Chạy cho đến khi hoạt động” mà không có time bound hoặc verification criteria.
- “Commit tất cả” trong repository có generated artifacts.
- “Expose toàn bộ home directory” cho tiện.
- “Tạo file link cho toàn workspace”.
- Chạy public deployment với
LOCAL_SHELL_MCP_AUTH_MODE=none.