A code \({\mathcal {C}}\) is a subset of the vertex set of a Hamming graph H(n, q), and \({\mathcal {C}}\) is 2-neighbour-transitive if the automorphism group \(G={{\,\textrm{Aut}\,}}({\mathcal {C}})\) acts transitively on each of the sets \({\mathcal {C}}\) , \({\mathcal {C}}_1\) and \({\mathcal {C}}_2\) , where \({\mathcal {C}}_1\) and \({\mathcal {C}}_2\) are the (non-empty) sets of vertices that are distances 1 and 2, respectively, (but no closer) to some element of \({\mathcal {C}}\) . Suppose that \({\mathcal {C}}\) is a 2-neighbour-transitive code with minimum distance at least 5. For \(q=2\) , all ‘minimal’ such \({\mathcal {C}}\) have been classified. Moreover, it has previously been shown that q must be a prime power, and a subgroup of the automorphism group of such a code induces a well-defined affine 2-transitive group action on the alphabet of the Hamming graph. The main results of this paper are to show that this affine 2-transitive group must be a subgroup of \(\textrm{A}\Gamma \textrm{L}_1(q)\) and to provide a number of infinite families of examples of such codes. These examples are described via polynomial algebras related to representations of certain classical groups.