We investigate the evolution of NOAA Active Region 11817 during 2013 August 10-12, when it developed a complex field configuration and produced four confined, followed by two eruptive, flares. These C-and-above flares are all associated with a magnetic flux rope (MFR) located along the major polarity inversion line, where shearing and converging photospheric flows are present. Aided by the nonlinear force-free field modeling, we identify the MFR through mapping magnetic connectivities and computing the twist number T w for each individual field line. The MFR is moderately twisted (|T w | < 2) and has a well-defined boundary of high squashing factor Q. We found that the field line with the extremum |T w | is a reliable proxy of the rope axis, and that the MFR's peak |T w | temporarily increases within half an hour before each flare while it decreases after the flare peak for both confined and eruptive flares. This pre-flare increase 9 Max-Planck-Institut für Sonnensystemforschung, Justus-von-Liebig-Weg 3, 37077 Göttingen, Germany -2 -in |T w | has little effect on the active region's free magnetic energy or any other parameters derived for the whole region, due to its moderate amount and the MFR's relatively small volume, while its decrease after flares is clearly associated with the stepwise decrease in the whole region's free magnetic energy due to the flare. We suggest that T w may serve as a useful parameter in forewarning the onset of eruption, and therefore, the consequent space weather effects. The helical kink instability is identified as the prime candidate onset mechanism for the considered flares.