Abstract. In this paper, we present a more effective approach to clustering with eXtended Classifier System (XCS) which is divided into two phases. The first phase is the XCS learning process with rule compact, during which we alter the XCS mechanisms and propose a new way to calculate rewards. After learning, the rules are evolved to form the final population consisting of rules with homogeneous data distribution. The second phase is merging the learnt rules to generate final clusters. We achieve this by modelling the rules as sub-graphs and merging the subgraphs based on some criteria similar to CHAMELEON. Experimental results validate the effectiveness on a number of datasets, which contain clusters of different shapes, densities and distances.