  Lensing by galaxy clusters is a versatile probe of cosmology and
extragalactic astrophysics, but the accuracy of some of its predictions is
limited by the simplified models adopted to reduce the (otherwise untractable)
number of degrees of freedom. We aim at cluster lensing models where the
parameters of all cluster-member galaxies are free to vary around some common
scaling relations with non-zero scatter, and deviate significantly from them if
and only if the data require it. We have devised a Bayesian hierarchical
inference framework, which enables the determination of all lensing parameters
and of the scaling-relation hyperparameters, including intrinsic scatter, from
lensing constraints and (if given) stellar kinematic measurements. We achieve
this through BayesLens, a purpose-built wrapper around common parametric
lensing codes for the lensing likelihood that can sample the posterior on
parameters and hyperparameters, which we release with this paper. We have run
functional tests of our code against simple mock cluster lensing datasets with
realistic uncertainties. The parameters and hyperparameters are recovered
within their 68% credibility ranges, and the positions of all the "observed"
multiple images are accurately reproduced by the BayeLens best-fit model,
without overfitting. We have shown that an accurate description of cluster
member galaxies is attainable, despite the large number of degrees of freedom,
through fast and tractable inference. This extends beyond the state-of-the-art
of current cluster lensing models. The precise impact on studies of
cosmography, galaxy evolution and high-redshift galaxy populations can then be
quantified on real galaxy clusters. While other sources of systematics exist
and may be significant in real clusters, our results show that the contribution
of intrinsic scatter in cluster-member populations can now be controlled.
