Is there an AJAX command I can use to debug PHP variables without breaking AJAX call? I know the list of Ajax framework commands. Every one of them is doing something useful. But sometimes I want, for debug, include a piece of debug data in my AJAX response. I want it to be unobtrusive, so var_dump is out. I need to wrap my debug data in some kind of command. On the other hand, I will view it using JS console, so I don't want it to actually change anything on my page. And changing something hidden with CSS is not feasible - I'm not in charge of CSS here. So it leaves me with commands approach.

Which command could I use for this purpose?

I was thinking about ajax_command_append with selector that will never be found, but I don't want to introduce any additional errors in my JavaScript Console.

Debugging it with xdebug is not, currently, possible, and I would rather avoid spending time and resources on creating VM, when what I need is something I can do with simple var_dump on non-AJAX pages.
As far as I know, there isn't such logging or "nulling" Ajax command. That doesn't mean you can't build any! I for example, have created some custom Ajax commands, and also a eval() so I can run some quick codes. 

1: Define the JS action

You need to add a new JS  file, or merge as necessary. Note this document.ready event is important (this is just the definition, so no need to be a behavior).

(function($){
    $(function() {
        Drupal.ajax.prototype.commands.js_eval = function(ajax, data, status) {
            eval(data.script);
        };
        Drupal.ajax.prototype.commands.console_log = function(ajax, data, status) {
            console.log(data.var);
        };
    });
})(jQuery);


2: The Ajax render array

Assuming you are aware of the ajax_render() and JS renderable arrays, it's time to create your own custom command. 

function mymodule_ajax_command_js_eval($script) {
  return array(
    'command' =&gt; 'js_eval',
    'script' =&gt; $script,
    'my_custom' =&gt; 'my custom value',
  );
}
function mymodule_ajax_command_console_log(&amp;$var) {
  return array(
    'command' =&gt; 'console_log',
    'var' =&gt; $var,
  );
}


Above PHP function is not really a hook, and can be any name you want. For the sake of convention, I'm using ajax_command in the function name.  In the return array, command will be called from Drupal.ajax.prototype.commands scope. You can pass additional variables, and they will be in the data for JS to access (data.my_custom, data.script, likewise.)

3: Now call it!

Now that you have the JS and PHP ends, time to call the function!

$output = array();
// $output[] = ajax_command_append('#some_random_id_that_you_d_normally_use', $html);
$output[] = mymodule_ajax_command_js_eval("alert('Big Bang Theory S8!)");
$output[] = mymodule_ajax_command_console_log($stuff_you_d_normally_dpm);

print ajax_render($output);
exit;