Regex-search a Swift file (no LSP)
swiftSearchPatternSearch Swift source files with pure regex to detect closure capture lists, Task blocks, and other patterns missed by LSP. Returns matched lines with positions and snippets.
Instructions
[mg.code] Pure regex search over a file's contents — no SourceKit-LSP, no IndexStoreDB. Catches what LSP misses: closure capture lists ([weak self], [unowned self]), Task { ... self ... } blocks, and any other pattern the agent constructs from a leak chain. Returns matches with line/character positions and a trimmed snippet.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"filePath": "<filePath>",
"pattern": "<pattern>"
},
"name": "swiftSearchPattern"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absolute path to a Swift source file. | |
| pattern | Yes | Regex pattern (JavaScript flavour). The `g` flag is implied — every match is returned. | |
| flags | No | Additional RegExp flags ("i", "m", "s", "im", etc.). | |
| maxMatches | No | Cap on matches returned (default 50). |