To make all .SD columns available, you just need to specify it somewhere in your j expression. For example, try the following:
x[,{.SD; browser(); a+1},by=id]
This works because as described here
[.data.table() [...] looks through an unexpressed j-expression and adds only to the .SD columns to which they refer. If .SD itself is mentioned, it adds all the DT columns.
Alternatively, if you do not want to bear the cost of loading .SD columns for each group calculation, you can always check the currently loaded subset of x by calling x[.I,] . ( .I is a variable that stores the location of the lines in x current group):
x[,{browser(); a+1},by=id]
source share