  A modified formulation of the Schr\"odinger functional (SF) is proposed. In
the continuum it is related to the standard SF by a non-singlet chiral field
rotation and therefore referred to as the chirally rotated SF ($\chi$SF). On
the lattice with Wilson fermions the relation is not exact, suggesting some
interesting tests of universality. The main advantage of the $\chi$SF consists
in its compatibility with the mechanism of automatic O($a$) improvement. In
this paper the basic set-up is introduced and discussed. Chirally rotated SF
boundary conditions are implemented on the lattice using an orbifold
construction. The lattice symmetries imply a list of counterterms, which
determine how the action and the basic fermionic two-point functions are
renormalised and O($a$) improved. As with the standard SF, a logarithmically
divergent boundary counterterm leads to a multiplicative renormalisation of the
fermionic boundary fields. In addition, a finite dimension 3 boundary
counterterm must be tuned in order to preserve the chirally rotated boundary
conditions in the interacting theory. Once this is achieved, O($a$) effects
originating from the bulk action or from insertions of composite operators in
the bulk can be avoided by the mechanism of automatic O($a$) improvement. The
remaining O($a$) effects arise from the boundaries and can be cancelled by
tuning a couple of O($a$) boundary counterterms. The general results are
illustrated in the free theory where the Sheikholeslami-Wohlert term is shown
to affect correlation functions only at O($a^2$), irrespective of its
coefficient.
