name: xlflow description: Use when Codex or another AI agent needs to edit, test, debug, or validate Excel VBA workbooks with xlflow. Provides the safe VBA development workflow for xlflow projects, including pull/push, lint, run, test, diff, XlflowUI dialog and file dialog wrapper guidance, headless dialog responses, failure handling, and final reporting rules.
xlflow Skill
Purpose
Use xlflow as the proof loop for Excel VBA work. Do not treat generated VBA as complete until the workbook has been exported or inspected, source has been changed, changes have been imported, and the relevant macro or tests have been run.
Default safety rules for AI-agent work:
- Usually start with
xlflow session startand stay in that session until the task is done. - When a task involves creating, fixing, or reasoning about workbook-side tests, load references/testing.md before editing test VBA. It covers discovery rules,
XlflowAsserthelpers, lifecycle hooks, tags/filters, and failure diagnosis. - If it is unclear whether source files or the workbook are newer, start the session and run
xlflow pull --session --json. - When
[vba].folders=true, treat the filesystem layout under each configured[src]root as meaningful architecture. Nested directories map to Rubberduck-compatible@Folder(...)annotations duringpush. - If
pushorrunleaves the live session workbook unsaved, treat the live workbook as newer than disk untilxlflow save --json. xlflow inspect workbook|sheets|range|used-range|cellreads the saved workbook file by default, but these commands accept--sessionwhen you need the live workbook currently open in Excel.- Use
xlflow list forms --session --jsonwhen you need workbook UserForm names or expected.frm/.frxsource paths without loading the form at runtime. - Use
xlflow inspect form <FormName> --runtime|--designer|--both --session --jsonwhen you need structured UserForm state beyond saved worksheet snapshots. Runtime inspection executes against a temporary workbook copy of the current source state. - Use
xlflow form snapshot <FormName> --out src/forms/specs/<FormName>.yaml --session --jsonwhen you need a persisted JSON/YAML spec for design review or future declarative UserForm workflows. This path is stricter thaninspect form --designerbecause it executes an injected helper to recover concrete control types. - Use
xlflow form build <spec> --session --jsonwhen you need to create a Designer-backed UserForm from a persisted spec undersrc/forms/specs/. - Use
xlflow form build <spec> --session --overwrite --jsonwhen the intended workflow is to replace an existing UserForm from spec rather than mutate it in place. - Use
xlflow form export-image <FormName> --out <path> --session --jsonwhen visual verification depends on the runtime-rendered UserForm rather than structured inspection alone. Treat it as secondary visual confirmation because the capture path is experimental; preferinspect formorform snapshotas the authoritative shape/state source. - When a task depends on UserForm spec authoring or review, load references/forms.md before choosing
inspect form,form snapshot, orform build. It defines the persistedxlflow.userformschema, flatcontrolscontract, overwrite safety rules, supported control types, and the best-effort versus observed-only fields that should not be treated as round-trip guarantees. - When a task depends on
MsgBox,InputBox, file pickers, or other interactive VBA prompts, load references/xlflow-ui.md before editing. Agent-authored dialog flows should default toXlflowUIwrappers with stable dialog ids sorunandtestcan stay headless. - When a dialog needs a workbook-side fallback if
runortestomits a scripted response, use the optionalDefaultResponse/DefaultValueparameters onXlflowUI.MsgBox,XlflowUI.InputBox, and the file dialog wrappers. - When headless dialog flows need realtime terminal visibility, add
--ui-streamtoxlflow runorxlflow test. It streams resolvedXlflowUIevents to stderr without breaking--jsonstdout, and InputBox values stay redacted by default. - When you need terminal-visible debug logs from workbook code, prefer explicit
XlflowDebug.Logcalls over rawDebug.Print.runandteststreamXlflowDebug.Logto stderr by default and return the recent lines under top-leveldebugin JSON output. - Treat
src/forms/specs/*.yamlas the canonical source-controlled artifact for UserForm design. Code-behind authority depends on[userform].code_source: new projects default tosidecar, wheresrc/forms/code/*.basis canonical, while imported projects default tofrm, where embedded.frmcode remains canonical until migration..frm/.frxare generated Designer artifacts. Afterxlflow form build, xlflow now re-materializes those artifacts back intosrc/forms/, andpushblocks before Excel opens when spec filename,form.name,.frmbasename, or.frmAttribute VB_Namedisagree. - Use
xlflow export-imagewhen verification depends on rendered appearance rather than saved workbook cell/style snapshots alone. - Use
xlflow edit --sessionfor temporary workbook-state setup, event triggering, and visual tuning when the change does not belong in production VBA yet. xlflow runreturns structured compile diagnostics by default. Use--gui-compile-errorsonly when a human explicitly wants raw Excel/VBE compile dialogs.- When the macro argument is omitted,
xlflow runusesproject.entryfromxlflow.toml.
Session Lifecycle
For normal AI-agent development tasks, use an explicit xlflow session from task start to task end:
- Start with
xlflow session startafter readingxlflow.tomland resolving source-of-truth questions. - Matching sessions are auto-reused for
list forms,inspect form,form snapshot,form build,form export-image,pull,push,macros,run,export-image,test,save,ui button add,ui button list, andui button removewhen the configured workbook path matches.xlflow/session.json; add--sessionwhen you want that reuse to be explicit. - Prefer
xlflow push --fast --session --no-save --jsonwhile iterating, and usexlflow run --session --jsonorxlflow run --headless --session --jsonwhenproject.entryis the intended entrypoint because structured compile diagnostics are on by default. - Save with
xlflow save --jsonbefore any disk-based verification step such asxlflow inspect ...when the live session workbook may be newer than disk. - End with
xlflow save --jsonwhen workbook changes must persist, then always runxlflow session stop.
Use isolated non-session commands only for one-shot CI-style verification, release checks, suspicious session state, or when the user explicitly asks not to keep Excel open.
If xlflow push --session --no-save succeeds, or xlflow run --session completes without --save or --save-as, treat the live workbook as potentially newer than the .xlsm on disk until xlflow save runs.
Standard Workflow
Inspect the project.
- Read
xlflow.toml. - Treat the configured source directories as authoritative when
xlflow.tomlexists and the user has not said the workbook contains newer VBA. - Run
xlflow doctor --jsonwhen Excel, COM, VBIDE, or macro execution looks suspicious. - Start
xlflow session startfor normal AI-agent development once the source of truth is clear. - Run
xlflow pull --session --jsonbefore editing when the workbook is the current source of truth.
- Read
Edit source files.
- Prefer
.bas,.cls, and.frmfiles under the configured source directories. - In folder mode, move files by directory when you want to change Rubberduck folder organization;
pushrewrites@Folder(...)from path in temporary import copies. - Do not edit binary workbooks directly unless the task is explicitly workbook-state only.
- Prefer
Import and check.
- Prefer
xlflow push --fast --session --no-save --jsonafter source edits while the session is running. - Use plain
xlflow push --jsonfor CI-style verification, release checks, or when session state is suspect. - Run
xlflow lint --jsonand fix reported issues before finalizing.
- Prefer
Execute behavior.
- Prefer
xlflow test --session --json. - Use
xlflow test --filter <name> --session --jsonwhile iterating on one failing test. - If the macro entrypoint is unclear, run
xlflow macros --session --jsonbefore choosing a target. - If no tests exist and
project.entryis the intended target, runxlflow run --session --json. - Use
xlflow run <MacroName> --session --jsonwhen you need a non-default entrypoint. - Prefer
xlflow run --headless --session --jsonwhenproject.entryis correct for unattended agent work that should still use the open session. - Use
xlflow run <MacroName> --headless --session --jsonwhen you need a non-default headless entrypoint. - In projects scaffolded by recent xlflow versions, prefer branching on
XlflowRuntime.ModeName()/IsHeadless()/IsAgent()/IsTest()instead of guessing execution context from UI state or process ancestry. - When a macro or test uses
XlflowUI.MsgBox,XlflowUI.InputBox, orXlflowUIfile dialog wrappers, keep unattended validation headless by passing repeated--msgbox <dialog-id=result>,--inputbox <dialog-id=value>, and--filedialog <kind>:<dialog-id>=<value>flags toxlflow runorxlflow test. - Add
--ui-streamwhen the agent or user needs realtime confirmation of which headless dialog path was taken. Expect stderr lines such asxlflow: ui kind=msgbox id=confirm-save source=default result=yesandxlflow: ui kind=file-open id=source-files source=scripted value=C:\temp\a.txt | C:\temp\b.txt, plus finalui.eventsin JSON or a UI section in human output. - Use
xlflow run <MacroName> --interactive --jsononly when a human can operate Excel dialogs or forms.
- Prefer
Inspect workbook results.
- Use
xlflow list forms --session --jsonwhen the workbook contains UserForms and you need the authoritative form names before planninginspect form, snapshot, or source review work. - Use
xlflow inspect form <FormName> --runtime --session --jsonto read runtime state after form initialization or workbook-driven population logic; xlflow runs it against a temporary workbook copy so the source workbook state is preserved. - Use
xlflow inspect form <FormName> --designer --session --jsonto inspect design-time controls and geometry without running workbook VBA. - Use
xlflow form snapshot <FormName> --out src/forms/specs/<FormName>.yaml --session --jsonwhen you want that design-time state persisted as a reviewable JSON/YAML spec and you need concrete control types from the stricter helper path. - Use
xlflow form export-image <FormName> --out <path> --session --jsonwhen you need a PNG of the runtime-rendered UserForm for visual review. - Use
xlflow inspect form <FormName> --both --session --jsonwhen you need to compare designer state against runtime state in one pass. - Add
--initializer <MethodName>to runtime or both mode when the form must be explicitly populated before inspection, such as workbook-scoped setup methods that mirror the visible UI. - Use
xlflow edit cell --sheet <name> --cell <A1> --value <text> --events on --session --jsonto prepare input cells and triggerWorksheet_Changehandlers during a session. - Use
xlflow edit range --sheet <name> --range <A1:B2> --fill <#RRGGBB> --session --jsonor--clear contents|formats|allto reset workbook state between iterations. - Use
xlflow edit rows --sheet <name> --rows <1:31> --height <points> --session --jsonandxlflow edit columns --sheet <name> --columns <A:AE> --width <chars> --session --jsonfor visual tuning beforeexport-image.
- Use
- Use
xlflow inspect workbook --jsonfor saved-file metadata, orxlflow inspect workbook --session --jsonfor the live workbook state in Excel. - Use
xlflow inspect sheets --jsonfor saved-file sheet metadata, orxlflow inspect sheets --session --jsonfor the live workbook state in Excel. - Use
xlflow inspect range --sheet <name> --address <A1:F20> --jsonwhen the expected saved-file output range is known. - Use
xlflow inspect range --sheet <name> --address <A1:F20> --session --jsonwhen the workbook output is still only in the live session. - Add
--include-stylewhen visual correctness depends on fill colors, borders, merged cells, row heights, or column widths. - Use
xlflow inspect used-range --sheet <name> --jsonwhen the output bounds are unknown and you need the current data rectangle. - Use
xlflow inspect cell --sheet <name> --address <A1> --jsonfor targeted assertions on one cell. - Use
xlflow export-image --sheet <name> --range <A1:F20> --session --jsonwhen verification depends on the rendered sheet appearance, chart placement, fills, or layout. - Prefer global
--jsonfor agent parsing. Use--format markdownonly when you intentionally want a compact human/LLM-facing table. - If the live session workbook is newer than disk, either run the matching
inspect ... --sessioncommand or runxlflow save --jsonbefore relying on file-backed inspect.
Compare results.
- Use
xlflow diff <before> <after> --jsonfor workbook state changes. - Add
--vba-before <dir> --vba-after <dir>when exported source changes also need review.
- Use
Repeat until the command results prove the task.
- Finish every normal AI-agent development task with
xlflow save --jsonwhen workbook changes must persist, thenxlflow session stop.
- Finish every normal AI-agent development task with
Project Orientation
Before editing, decide what is authoritative:
- If
xlflow.tomlexists and source files are present, start a session, edit the configured source tree, and usexlflow push --fast --session --jsonduring normal development. - If the user says the workbook has the latest VBA, or source files are missing or stale, run
xlflow pull --session --jsonafter starting the session, then edit source files. - Do not mix direct workbook edits with source edits in the same task unless the requested change is workbook-state only and no VBA source change is needed.
- Treat
xlflow inspectwithout--sessionas a disk snapshot reader. If the task depends on unsaved session changes, either inspect with--sessionor save first.
Before running a macro, decide the runnable entrypoint:
- Run
xlflow macros --session --jsonwhen the macro name is not already proven by tests, docs, prior command output, orproject.entry. - If
project.entryis the intended entrypoint, prefer plainxlflow run --session --jsonover repeating the macro name. - Use a listed
qualified_namefromxlflow macros --session --json; do not assume names such asMain.Run. - If the desired entrypoint is missing, add or fix the source module, run
xlflow push --fast --session --jsonwhen a session is active, then rediscover macros before running.
Before designing a CLI-run macro, decide how inputs are supplied:
- Prefer
xlflow run <MacroName> --arg <type:value>for user-provided paths, flags, and scalar settings. - Use deterministic paths, environment variables, or configuration cells only when they are part of the project contract.
- Do not introduce raw
MsgBox,InputBox, or file dialog calls in agent-authored VBA. UseXlflowUI.MsgBox,XlflowUI.InputBox,XlflowUI.GetOpenFilename,XlflowUI.FileDialogOpen,XlflowUI.GetSaveAsFilename, andXlflowUI.FolderPickerwith stable dialog ids and plan the matching--msgbox,--inputbox, and--filedialogresponses for headless or test runs. - Avoid other UI prompts and active-window assumptions because unattended Excel automation cannot reliably answer them.
- When GUI behavior is required, keep the GUI entrypoint thin and extract the core logic into parameterized procedures that can run with
xlflow run --headless --arg, or route simple dialogs and file pickers throughXlflowUI.
Decision Flow
When the user asks to create or change VBA behavior:
- Read
xlflow.tomland relevant source files. - Start
xlflow session startunless the task is a one-shot CI-style check, session state is suspect, or the user explicitly wants isolated commands. - If the current source of truth is unclear, run
xlflow pull --session --jsonbefore editing. - Edit
.bas,.cls, or.frmsource files. - Run
xlflow push --fast --session --no-save --json. - Run
xlflow lint --json. - Run
xlflow test --session --jsonwhen tests exist.- Use
xlflow test --filter <name> --session --jsonfor focused iteration. - Use
xlflow test --module <ModuleName> --session --jsonto run one suite. - Use
xlflow test --tag <tag> --session --jsonfor tag-based subsets. - Load references/testing.md when writing new tests, adding hooks, or debugging test failures.
- Use
- If tests do not cover the behavior, run
xlflow macros --session --json, thenxlflow run --headless --session --jsonwhenproject.entryis correct, orxlflow run <qualified_name> --headless --session --jsonfor non-default entrypoints. AddXlflowDebug.Logbefore rerunning if internal runtime state is still unclear. - When workbook output matters, run
xlflow save --jsonif needed, then inspect the result withxlflow inspect workbook|sheets|range|used-range|cell --json, or usexlflow inspect form <FormName> --session --jsonfor live UserForm state. - Run
xlflow save --jsonwhen workbook changes must persist, thenxlflow session stop. - Use
xlflow diff <before> <after> --jsonwhen workbook state changes must be reviewed.
When the user reports a runtime failure:
- Start
xlflow session start, then reproduce withxlflow test --session --jsonorxlflow run <qualified_name> --session --json. - Inspect
error.code,error.phase, VBA error metadata,run_diagnostic, and any returneddebug.eventsbefore changing source. - Run
xlflow doctor --jsonfor setup phases such asopen_workbook,prepare_vbide, orinject_harness. - If the failure location is still unclear, load references/debugging.md and follow the line-number plus
XlflowDebug.Logworkflow there. - Patch the smallest relevant source area, then rerun the reproduction and broader verification.
Command Usage
- Use
xlflow doctor --jsonbefore blaming VBA when Excel automation fails before user code starts. - Use
xlflow session startat the beginning of normal AI-agent development tasks, and usexlflow session stopbefore finalizing. - Use
xlflow pull --session --jsonto refresh editable source from the configured workbook during a session. - Use
xlflow push --fast --session --no-saveafter source edits during a session. - Use plain
xlflow pushwhen you need the safe isolated path with backup and save. - Use
xlflow backup list --jsonto find rollback targets after a brokenpushor workbook-level mistake. - Use
xlflow rollback --latest --jsonorxlflow rollback --backup <id> --jsononly after the workbook is closed or the xlflow session has been stopped; then runxlflow pull --jsonif source files should match the restored workbook. - Use
xlflow lintas the fast safety gate for generated VBA. - Use
xlflow test --session --jsonas the primary correctness signal when tests exist. - Use
xlflow test --module <ModuleName> --session --jsonto run only the tests in one module. - Use
xlflow test --tag <tag> --session --jsonto run only tests matching a tag. - Use
xlflow test --filter <TestName> --session --jsonfor exact-name focused iteration. - Read references/testing.md for detailed guidance on
XlflowAssert, lifecycle hooks, tag conventions, and failure diagnosis. - Use
xlflow macros --session --jsonto discover runnable macro entrypoints before guessing a non-defaultruntarget. - Use
xlflow inspect workbook --jsonto confirm saved workbook metadata after save, orxlflow inspect workbook --session --jsonto inspect the live workbook before saving. - Use
xlflow inspect sheets --jsonto verify saved worksheet names, visibility, and lightweight used ranges, orxlflow inspect sheets --session --jsonfor the live workbook. - Use
xlflow inspect range --sheet <name> --address <A1:F20> --jsonwhen the expected saved-file output rectangle is known. - Use
xlflow inspect range --sheet <name> --address <A1:F20> --session --jsonwhen the expected output rectangle is still only in the live workbook. - Use
xlflow inspect used-range --sheet <name> --jsonwhen the output rectangle is unknown or may expand. - Use
xlflow inspect cell --sheet <name> --address <A1> --jsonfor single-cell checks or precise assertions. - Use
xlflow inspect form <FormName> --runtime|--designer|--both --session --jsonfor UserForm inspection; prefer--designerfor source/design audits,--runtimefor populated runtime state from a temporary workbook copy, and--bothwhen you need to compare them.- Use
xlflow form snapshot <FormName> --out src/forms/specs/<FormName>.yaml --session --jsonwhen the goal is a stable artifact for review, diff, or later declarative form work rather than one-off stdout inspection. - Use
xlflow form build src/forms/specs/<FormName>.yaml --session --jsonto materialize a new UserForm from a saved spec; add--overwritewhen replacing an existing component intentionally.
- Use
- Use
xlflow form export-image <FormName> --out <path> --session --jsonwhen the question is visual fidelity of the runtime form, including layout after initialization. - Use
xlflow inspect form <FormName> --runtime --initializer <MethodName> --session --jsonwhen the form requires an explicit initializer call before its visible state is meaningful. - Use
xlflow save --jsonbefore file-backedinspectwhenever a session run orpush --session --no-savemay have left newer workbook state only in the live Excel instance. - Treat
xlflow inspect workbook|sheets|range|used-range|cellwithout--sessionas disk-backed workbook readers,xlflow inspect ... --sessionas live Excel inspectors, andxlflow inspect formas a specialized Excel COM inspection command whose runtime mode executes against a temporary workbook copy derived from the current source workbook state. - When UserForms are involved, treat
pull/push/savewarnings about partial.frmfidelity and unsaved session state as actionable; do not review UserForm diffs until the live workbook has been saved and re-pulled. - Use
xlflow inspect-gui --jsonwhen a macro may require file pickers, message boxes, UserForms, or external process launches. - If a headless macro still needs simple confirmation, scalar input, or file selection, replace raw dialogs with
XlflowUIand rerun with repeated--msgbox,--inputbox, and--filedialogflags instead of suppressing the boundary. - If headless
XlflowUIbehavior itself is under investigation, rerun with--ui-streambefore adding extra logs. Use the streamed stderr lines for realtime progress and the finalui.eventspayload orUIsection for post-run confirmation. - Use
xlflow edit --sessiononly for development-time workbook mutations; if the final application behavior depends on the styling or layout change, move that behavior back into reproducible VBA before finalizing. - Use
xlflow run --headless --sessionfor repeatable automation during normal development; if it reportsgui_boundary_detected, explain that the preflight scans the configured source tree rather than the target macro call graph, then either refactor the macro or rerun with--interactivewhen a human is available. - If
lintreportsVB007for rawMsgBox,InputBox, or file dialog calls, replace them withXlflowUIwrappers before considering suppression. Use[lint].forbid_interactive_input = falseonly for genuinely human-only projects, and do not imply that this changesrun --headless; headless preflight still blocks GUI boundaries. - Plain
xlflow run --session --jsonalready compiles first, usesproject.entrywhen the macro argument is omitted, and returns structured compile diagnostics by default. - Use
xlflow run --fast --session --gui-compile-errorsonly when a human explicitly accepts GUI compile dialogs and you intentionally want the direct fast path. Plainxlflow run --directalready opts out of default compile diagnostics automatically. - Use
xlflow run --gui-compile-errors --interactive --jsononly when a human explicitly wants raw compile dialogs instead of structured diagnostics. - Matching workbook sessions auto-reuse on
list forms,inspect form,form snapshot,form build,form export-image,pull,push,macros,run,export-image,test,save,ui button add,ui button list, andui button remove; use explicit--sessionwhen you want that reuse to be deliberate and visible in the command line. - Use
xlflow attach --active --jsonbefore human-assisted sessions to confirm that the open Excel workbook matchesxlflow.toml. - Use
xlflow run --session --jsonwhen tests are absent or the macro mutates workbook state. If more internal state is needed, addXlflowDebug.Logand rerun. - Use
xlflow diffto summarize workbook and optional exported VBA differences.
VBA Coding Rules
- Always use
Option Explicit. - Avoid
Select,Activate,ActiveSheet, and unqualifiedRange. - Prefer explicit workbook and worksheet references.
- Use
Longinstead ofInteger. - Keep procedures small and move business logic into testable standard modules.
- Restore
Applicationstate in cleanup paths. - Use
On Error GoTo ErrHandler; avoid broadOn Error Resume Next. - Do not pass object or array values to
AssertEquals; compare scalar properties such asRange.Value2. - Do not introduce raw
MsgBoxorInputBoxoutsideXlflowUI.basor a deliberate interactive-only adapter. UseXlflowUI.MsgBox/XlflowUI.InputBoxwith stable dialog ids, and load references/xlflow-ui.md when designing dialog flows. - Avoid other UI prompts such as
Application.GetOpenFilename,Application.GetSaveAsFilename,Application.FileDialog, andUserForm.Showin macros that must run headlessly. Preferrun --arg, environment variables, configuration cells, deterministic paths, or an interactive-only adapter. - Structure GUI-dependent macros with a human-facing entrypoint and a headless core:
Public Sub ImportData()
Dim path As String
path = PickImportFilePath()
If path = "" Then Exit Sub
ImportDataFromPath path
End Sub
Public Sub ImportDataFromPath(ByVal path As String)
' Core logic here
End Sub
Progress Rules
Use normal Excel COM-backed commands with or without --json; xlflow reports progress on stderr. Interactive terminals show a spinner, non-interactive or --json runs fall back to a single stderr progress line, and commands that stream UI/debug events may suppress separate progress output so those stderr records stay parseable.
After starting a workbook-dependent command, wait for the process to exit before beginning the next step. Do not synchronize on transient stderr frames or assume silence means the command is stalled.
Debug Rules
Use XlflowDebug.Log for VBA-internal execution-state logging and xlflow run --session --json or xlflow test --session --json for machine-readable execution results.
When debugging, add XlflowDebug.Log calls at procedure entry, important branches, row or column counts, external paths, before and after destructive operations, and error handlers.
Keep high-level progress debug logs if they help future diagnosis. Remove noisy temporary logs before finalizing.
XlflowDebug.Log "start GenerateReport"
XlflowDebug.Log "lastRow", lastRow
XlflowDebug.Log "finished GenerateReport"
Windows PowerShell Checklist
When workbook code launches an external PowerShell process, separate xlflow's bridge host from the workbook-side host:
- Check top-level
bridge.hostto see which PowerShell xlflow itself used. - Inspect the VBA command string or log the resolved executable from workbook code; it may be
powershell.exeeven when xlflow reportspwsh.exe, or the reverse. - If the issue looks like encoding or environment drift, standardize on one host before changing xlflow or VBA logic.
Excel Process Management
- Use
xlflow process listto list all local Excel processes. The output includes PID and whether each process has open workbooks. - Use
xlflow process cleanup <pid>to terminate a single Excel process by PID. The command tries graceful shutdown first and falls back to force-stop only if the process persists. - Use
xlflow process cleanup --autoto terminate only Excel processes that have no open workbooks. This is safe for cleaning up zombie Excel instances. - Use
xlflow process cleanup --allto force-terminate ALL Excel processes. WARNING:cleanup --allis a destructive operation that WILL terminate every Excel process on the local machine, including any with unsaved workbooks. This command always prompts for confirmation unless--yesis passed.
Failure Handling
If xlflow test fails, read the failing test name, module, error.code, VBA error number, description, and line. Distinct error.code values include test_failed, before_all_failed, after_all_failed, before_each_failed, after_each_failed, and test_inconclusive. Hook failures (before_all_failed, after_all_failed, before_each_failed, after_each_failed) indicate setup/cleanup problems rather than assertion failures in the test body. Load references/testing.md for a full failure-code reference. Patch the smallest relevant area, rerun the focused test with --filter first, then run the full test suite.
If xlflow run fails, inspect error.code, error.phase, and any top-level run_diagnostic. macro_not_found means the entrypoint is missing or invalid; run xlflow macros --session --json and correct the target before changing user code. Setup phases such as open_workbook, prepare_vbide, and inject_harness usually indicate environment, configuration, or VBIDE access problems. invoke_macro points at the target macro or code it calls. Plain run already includes compile-first diagnostics by default; do not switch to --gui-compile-errors unless a human explicitly wants GUI dialogs.
If xlflow run --headless --session --json fails with gui_boundary_detected, read gui_boundaries and do not retry the same command blindly. If the boundary is raw MsgBox or InputBox, replace it with XlflowUI and rerun with --msgbox / --inputbox. Otherwise refactor the GUI boundary behind a parameterized core procedure, or switch to xlflow run --interactive --json only when a human is ready to operate Excel. If macro_timeout is returned, suspect an unresolved dialog, file picker, UserForm, or long-running loop.
If xlflow run --diagnostic --session --json fails with vba_compile_failed, inspect run_diagnostic.kind, run_diagnostic.message, run_diagnostic.location, and run_diagnostic.nearby_code before changing source. Treat dialog text as localized opaque text and fix the selected source location when available.
If xlflow run --session --json fails, read debug.events, identify the last successful log line, add targeted XlflowDebug.Log calls around the suspected block, and rerun. If the failed run has no useful debug events, add an entry log at the macro start or verify the macro target with xlflow macros --session --json. For normal run debugging, prefer references/debugging.md and XlflowDebug.Log.
If a headless XlflowUI run behaves differently than expected, reproduce with the same --msgbox / --inputbox values plus --ui-stream. Compare the streamed stderr lines against the final ui.events payload to confirm which dialog ids resolved from scripted responses versus workbook defaults.
If xlflow lint fails, fix lint findings directly in source files before rerunning push, run, or test.
Run xlflow analyze --json or xlflow check --json before changing object-heavy VBA. Analyzer findings such as VBA101, VBA102, and VBA103 usually mean a missing Set assignment.
If xlflow inspect does not show the workbook changes you expected, first decide whether disk is stale. A prior xlflow push --session --no-save or xlflow run --session can leave the live Excel workbook newer than the saved .xlsm; run xlflow save --json and inspect again before assuming the macro logic failed.
If a UserForm inspection looks wrong, first decide whether you need design-time state or runtime state. Use xlflow inspect form <FormName> --designer for control layout and static properties, and --runtime when labels, combo contents, or text boxes are populated by code. If runtime values are blank but the visible UI should be initialized, rerun with --initializer <MethodName> before changing source.
If the structure looks right but the visible layout is still uncertain, use xlflow form export-image <FormName> --out <path> --session --json to capture the runtime-rendered form from a temporary workbook copy.
If xlflow inspect used-range is truncated, use the reported returned_range and warnings to choose a narrower follow-up xlflow inspect range query instead of blindly increasing prompt size.
If workbook correctness is visual and inspect still leaves ambiguity, use xlflow export-image --sheet <name> --range <A1:F20> --session --json and inspect the generated PNG artifact under .xlflow/artifacts/images/.
Final Response
Report:
- changed modules or files
- commands executed
- lint, test, macro, and diff results
- remaining risks or unverified conditions