A grid code is a technical specification which defines the parameters a facility connected to a public electric grid has to meet to ensure safe, secure and economic proper functioning of the electric system.
[1] The grid code is specified by an authority responsible for the system integrity and network operation.
[2] Contents of a grid code vary depending on the transmission company's requirements.
Typically, a grid code will specify the required behavior of a connected generator during system disturbances.
These include voltage regulation, power factor limits and reactive power supply, response to a system fault (e.g. short-circuit), response to frequency changes on the grid, and requirement to "ride through" short interruptions of the connection.