| layout | title | nav_order | parent |
|---|---|---|---|
default |
Chapter 3: File and Command Operations |
3 |
Roo Code Tutorial |
Welcome to Chapter 3: File and Command Operations. In this part of Roo Code Tutorial: Run an AI Dev Team in Your Editor, you will build an intuitive mental model first, then move into concrete implementation details and practical production tradeoffs.
This chapter covers the most common and risky Roo Code actions: patching files and executing commands.
- propose patch
- inspect diff
- approve/reject
- run validation command
- summarize evidence
| Dimension | Key Question |
|---|---|
| Scope | only intended files changed? |
| Correctness | logic aligns with task objective? |
| Risk | config/auth/security impacts introduced? |
| Compatibility | public interfaces still safe? |
| Validation | command evidence supports acceptance? |
- read-only commands can be broadly approved
- mutating commands require explicit confirmation
- destructive commands should be denylisted by default
- execution should stay inside repo scope
Document canonical commands per repository:
lint: pnpm lint
test: pnpm test
test:target: pnpm test -- <module>
build: pnpm build
This avoids trial-and-error shell behavior.
- one subsystem per iteration
- avoid unrelated formatting churn
- reject broad patch bundles with mixed objectives
- require summary per accepted patch
When command fails after patch:
- classify error (syntax, missing import, test regression, environment)
- patch only implicated area
- rerun targeted command first
- escalate to broader checks after targeted pass
Apply stricter review to:
- auth and permissions
- deployment and CI configuration
- secret and environment loaders
- billing and usage enforcement
For each accepted iteration, capture:
- files changed
- commands executed
- command outcomes
- residual risks or TODOs
This improves handoff and incident response.
You now have a governance model for Roo edit/command loops:
- bounded patching
- safe command execution
- deterministic validation
- audit-friendly evidence capture
Next: Chapter 4: Context and Indexing
The walk function in scripts/find-missing-i18n-key.js handles a key part of this chapter's functionality:
const results = []
function walk(dir, baseDir, localeDirs, localesDir) {
const files = fs.readdirSync(dir)
for (const file of files) {
const filePath = path.join(dir, file)
const stat = fs.statSync(filePath)
// Exclude test files and __mocks__ directory
if (filePath.includes(".test.") || filePath.includes("__mocks__")) continue
if (stat.isDirectory()) {
walk(filePath, baseDir, localeDirs, localesDir) // Recursively traverse subdirectories
} else if (stat.isFile() && [".ts", ".tsx", ".js", ".jsx"].includes(path.extname(filePath))) {
const content = fs.readFileSync(filePath, "utf8")
// Match all i18n keys
for (const pattern of i18nPatterns) {
let match
while ((match = pattern.exec(content)) !== null) {
const key = match[1]
const missingLocales = checkKeyInLocales(key, localeDirs, localesDir)
if (missingLocales.length > 0) {
results.push({
key,
missingLocales,
file: path.relative(baseDir, filePath),
})
}
}
}This function is important because it defines how Roo Code Tutorial: Run an AI Dev Team in Your Editor implements the patterns covered in this chapter.
The main function in scripts/find-missing-i18n-key.js handles a key part of this chapter's functionality:
// Execute and output the results
function main() {
try {
if (args.locale) {
// Check if the specified locale exists in any of the locales directories
const localeExists = Object.values(DIRS).some((config) => {
const localeDirs = getLocaleDirs(config.localesDir)
return localeDirs.includes(args.locale)
})
if (!localeExists) {
console.error(`Error: Language '${args.locale}' not found in any locales directory`)
process.exit(1)
}
}
const missingKeys = findMissingI18nKeys()
if (missingKeys.length === 0) {
console.log("\n✅ All i18n keys are present!")
return
}
console.log("\nMissing i18n keys:\n")
missingKeys.forEach(({ key, missingLocales, file }) => {
console.log(`File: ${file}`)
console.log(`Key: ${key}`)
console.log("Missing in:")
missingLocales.forEach((file) => console.log(` - ${file}`))
console.log("-------------------")
})This function is important because it defines how Roo Code Tutorial: Run an AI Dev Team in Your Editor implements the patterns covered in this chapter.
flowchart TD
A[walk]
B[main]
A --> B