Custom commands

in Japanese(日本語)

When the built-in DSL commands don't cover a repeated step in your own app (log in, a shared precondition, a custom multi-finger gesture assembled with gesture), write it as a plain Swift function under scenarios/.

func login(user: String, password: String) {
    type("#login_email", user)
    type("#login_password", password)
    tap("#btn_login")
    exist("#home_title")
}

Call it like any other step inside a scene:

scene(1, "Sign in") {
    action {
        login(user: account("[user1].id"), password: account("[user1].password"))
    }
}

Shareable values go in the project's dataset/accounts.json; passwords go in this Mac's ~/.config/fleetest/dataset/<project name>/accounts.json (Test data and accounts).

Listing it in the command index (@FTCommand)

A plain function like the one above works, but it doesn't show up anywhere — an agent writing scenarios with the MCP server (ft_dsl_commands) or the fleetest-scenario skill has no way to know it exists, so it never reuses it and may write the same steps out by hand instead. Mark the function with @FTCommand("summary") to list it in the command index:

@FTCommand("Logs in with email and password and waits for the home screen")
func login(user: String, password: String) {
    type("#login_email", user)
    type("#login_password", password)
    tap("#btn_login")
    exist("#home_title")
}

fleetest api dsl-commands --project <name> and the MCP tool ft_dsl_commands (called with project: — when omitted it resolves to your only project, then the machine setting's default project, then project1; if none of these decides, only the built-in commands are returned) now list it alongside the built-in commands, tagged [project: file:line] so its origin is clear. An agent asked to write a new scenario is told to prefer it over inventing similar steps by hand, because it encodes your team's own conventions (e.g. what "logged in" means for your app).

@FTCommand is a marker only — it generates no code. The function behaves exactly the same whether or not it's marked; marking it only makes it discoverable.

The index lists only the function's name, call shape, summary, and file and line — not its body. The MCP server builds the list by reading the scenario sources on this Mac and returns it only to the AI assistant connected to it (nothing is exposed on the network). Being listed does not make the function runnable through MCP (see ft_batch under "Rules" below). The summary is passed to the AI assistant, so write only what the function does.

extension FTElement methods

A helper that acts on a grabbed element can be written as an FTElement extension instead of a free function, so it chains the same way built-in commands like .textIs(...) do:

extension FTElement {
    @FTCommand("Taps this element and checks that the next element appears")
    @discardableResult
    func tapAndConfirm(_ next: String) -> FTElement {
        tap()
        return exist(next)
    }
}
select("#btn_add_to_cart").tapAndConfirm("#txt_cart_badge")

The index marks this kind of entry so a reader knows it's called as select(...).tapAndConfirm(...), not as a free function.

Rules