VS Code extension: Hide commands from command palette

The following snippet illustrates how to hide a command registered as 'extension.myHiddenCommand':

"contributes": {
    "commands": [
    {
        "command": "extension.myHiddenCommand",
        "title": "Compile folder"
    }],
    "menus": {
        "commandPalette": [
        {
            "command": "extension.myHiddenCommand",
            "when": "false"
        }]
    }
}

If you don't need to associate an "icon" or a "title" with your command, you can simply omit it from "commands" - commands that are not listed there can still be called, as long as they have been registered via vscode.commands.

Otherwise, you can use the following trick to hide it from the command palette:

"contributes": {
    "menus": {
        "commandPalette": [
            {
                "command": "extension.myCommand",
                "when": "false"
            }
        ]
    }
}