คู่มือปฏิบัติ
ให้ agent ทำรีแฟกเตอร์ขนาดเล็ก
จำกัดขอบเขต รักษาพฤติกรรมเดิม และตรวจทุก diff เพื่อให้ agent ทำรีแฟกเตอร์ขนาดเล็กอย่างตรวจสอบได้
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
อธิบายอย่างง่าย: An agent needs two layers of guardrails
หัวข้อที่มีชื่อว่า “อธิบายอย่างง่าย: An agent needs two layers of guardrails”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Perform a small refactor with tests as a safety net
ตัวอย่างขั้นต่ำ
หัวข้อที่มีชื่อว่า “ตัวอย่างขั้นต่ำ”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
Refactor src/parcel-label.js, give the functions clearer names, split things up,and optimize related code while you are there.ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
Analyze the code read-only first. Do not edit files yet. Rename the internalfunction formatTag to formatParcelTag, then extract string normalization intoone unexported helper. Observable behavior must not change.
Only src/parcel-label.js may change. Treat test/parcel-label.test.js as read-only.Do not add dependencies, change public exports, or format unrelated code. Firstlist the invariants and two independent steps. After I approve the plan, performone step at a time. Wait until I review the diff, run node --test, and create arollback point before continuing. Do not edit tests to manufacture a green run.ตัวอย่างฉบับเต็ม: Rename and split a label-formatting function
หัวข้อที่มีชื่อว่า “ตัวอย่างฉบับเต็ม: Rename and split a label-formatting function”วัสดุตั้งต้น
หัวข้อที่มีชื่อว่า “วัสดุตั้งต้น”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
function formatTag(record) { const name = record.name.trim().replace(/\s+/g, ' '); const zone = record.zone.trim().replace(/\s+/g, ' ').toUpperCase(); return `${name} · ${zone}`;}
export function buildParcelLabel(record) { if (!record || typeof record !== 'object') { throw new TypeError('record must be an object'); } return `To: ${formatTag(record)}`;}ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
import test from 'node:test';import assert from 'node:assert/strict';import * as labels from '../src/parcel-label.js';
const { buildParcelLabel } = labels;
test('keeps the public export stable', () => { assert.deepEqual(Object.keys(labels), ['buildParcelLabel']);});
test('normalizes spacing and uppercases the zone', () => { assert.equal( buildParcelLabel({ name: ' Mira Chen ', zone: ' north dock ' }), 'To: Mira Chen · NORTH DOCK', );});
test('rejects a missing record', () => { assert.throws( () => buildParcelLabel(null), { name: 'TypeError', message: 'record must be an object' }, );});หัวข้อ: State the scope and invariants first
หัวข้อที่มีชื่อว่า “หัวข้อ: State the scope and invariants first”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
[Goal]Rename the internal function formatTag to formatParcelTag and extract the repeatedtrim plus whitespace collapse into normalizeTagPart. Keep the observable behaviorof buildParcelLabel unchanged.
[Allowed change]Only modify src/parcel-label.js.
[Must not change]- The only public export remains buildParcelLabel(record).- Output remains "To: <name> · <UPPERCASE ZONE>".- Leading and trailing whitespace is removed, and consecutive whitespace becomes one space.- A missing record still throws the same TypeError with the same message.- test/parcel-label.test.js is read-only. Do not add dependencies, edit configuration, or use the network.- Do not commit or continue to the next step until I return the test and review result.
[Steps]1. Only rename formatTag to formatParcelTag and update its sole call site.2. Then extract an unexported normalizeTagPart(value) called by formatParcelTag.3. Provide only the minimal diff for the current step, then stop.ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Perform a small refactor with tests as a safety net
หัวข้อ: Create an isolated work area
หัวข้อที่มีชื่อว่า “หัวข้อ: Create an isolated work area”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
git status --shortgit switch -c refactor/parcel-taggit rev-parse HEADnode --testข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Create a project in the Antigravity app and review artifacts
หัวข้อ: Choose a mode and permission level for every step
หัวข้อที่มีชื่อว่า “หัวข้อ: Choose a mode and permission level for every step”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
| เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย |
|---|---|---|---|
| เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย |
| เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย |
| เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย |
| เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย | เนื้อหาภาษาไทย |
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Your first agent task: Use execution modes and permissions as guardrails Create a project in the Antigravity app and review artifacts Permissions and sandbox: what presets, rules, and the sandbox each control
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Before enabling auto or Turbo: risks, acceptable cases, and reversal
หัวข้อ: Step 1: Rename only the internal function
หัวข้อที่มีชื่อว่า “หัวข้อ: Step 1: Rename only the internal function”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
function formatTag(record) {function formatParcelTag(record) { const name = record.name.trim().replace(/\s+/g, ' '); const zone = record.zone.trim().replace(/\s+/g, ' ').toUpperCase(); return `${name} · ${zone}`; }@@ return `To: ${formatTag(record)}`; return `To: ${formatParcelTag(record)}`;ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
git diff -- src/parcel-label.jsgit add src/parcel-label.jsgit commit -m "refactor: rename internal parcel tag formatter"ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
หัวข้อ: Step 2: Extract the string-normalization helper
หัวข้อที่มีชื่อว่า “หัวข้อ: Step 2: Extract the string-normalization helper”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
function normalizeTagPart(value) { return value.trim().replace(/\s+/g, ' ');}
function formatParcelTag(record) { const name = record.name.trim().replace(/\s+/g, ' '); const zone = record.zone.trim().replace(/\s+/g, ' ').toUpperCase(); const name = normalizeTagPart(record.name); const zone = normalizeTagPart(record.zone).toUpperCase(); return `${name} · ${zone}`;}ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
git diff -- src/parcel-label.jsgit add src/parcel-label.jsgit commit -m "refactor: extract tag part normalization"ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
หัวข้อ: Final review
หัวข้อที่มีชื่อว่า “หัวข้อ: Final review”ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
git status --shortgit log --oneline <BASE_COMMIT>..HEADgit diff --name-status <BASE_COMMIT>..HEADgit diff <BASE_COMMIT>..HEAD -- src/parcel-label.js test/parcel-label.test.jsnode --testข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Review agent changes before you accept them Artifacts and plans: kinds, surface differences, and how to judge a plan
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
หัวข้อ: Anti-patterns and rewrites
หัวข้อที่มีชื่อว่า “หัวข้อ: Anti-patterns and rewrites”หัวข้อ: Anti-pattern 1: Enable auto or Turbo and finish in one pass
หัวข้อที่มีชื่อว่า “หัวข้อ: Anti-pattern 1: Enable auto or Turbo and finish in one pass”This is a small change. Complete everything, run the tests, and commit without asking me.ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
หัวข้อ: Anti-pattern 2: Trust only the agent’s summary
หัวข้อที่มีชื่อว่า “หัวข้อ: Anti-pattern 2: Trust only the agent’s summary”The agent says it changed only one file and all tests passed, so the branch is ready to merge.ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Review agent changes before you accept them
รายการตรวจสอบการยืนยันผล
หัวข้อที่มีชื่อว่า “รายการตรวจสอบการยืนยันผล”- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
การกู้คืนและขอบเขตความปลอดภัย
หัวข้อที่มีชื่อว่า “การกู้คืนและขอบเขตความปลอดภัย”- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Your first agent task: Use execution modes and permissions as guardrails
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
- ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ
ข้อความนี้อธิบายขั้นตอน ขอบเขต หลักฐานที่ต้องตรวจ และเงื่อนไขการกู้คืนตามตัวอย่างอย่างเป็นระบบ โปรดดู Perform a small refactor with tests as a safety net Permissions and sandbox: what presets, rules, and the sandbox each control Review agent changes before you accept them