Expression to get the current composition's width and height

var comp_width = thisComp.width;
var comp_height = thisComp.height;

Example usage:

/**
* Apply to the Size property of a rectangle shape layer
* This will automatically size a rectangle to the comp size
**/
var comp_width = thisComp.width;
var comp_height = thisComp.height;
[comp_width, comp_height];

More advanced examples:

Expression to put a layer in the centre of a composition

Apply the following expression to the position property of a layer:

var centre_x = thisComp.width / 2;
var centre_y = thisComp.height / 2;
[centre_x, centre_y];