Retrieve Context Key inside snippets. See https://forums.modx.com/thread/30357/solved-return-the-current-context-key for more details.
<?php
/*
* Usage [[!getContext? &id=``]]
*/
//retrieve ID or use current resource
$id = (!empty($id) ? $id : $modx->resource->get('id'));
//retrieve context
$page = $modx->getObject('modResource', $id);
$output = $page->get('context_key');
//return output
return $output;
<?php
/*
* Usage [[!contextKey]]
* */
return $modx->context->key;