It's pretty easy to get to CT from Lucca except that everyone else is also doing it.
The Lucca train station is just outside the city walls and you can book a train to La Spezia. You'll need to change trains - probably either in Pisa or in Viareggio - and it will take about an 1:30. These are local tickets so no need to book in advance.
When you change trains you will run into all the day trippers from Florence heading to CT and train may be crowded or very crowded by the time you join it. Unless you get really lucky and the train you are on also stops in one of the CT towns after La Spezia you will need to get out in La Spezia and catch a local CT train with everyone else.
At this point I have to point out that the Trenitalia app will allow you to check schedules and book tickets so you could already have a ticket for the next CT train and know when it is before you get off in La Spezia. Everyone without the app will be crowding the long line for the ticket kiosks but not you.
The other option is to take the ferry which is about a mile from the train station downhill to the harbor. Like the Amalfi Coast I think CT is best appreciated from the ocean and I would encourage you to do this trip at least once if not right when you get there.
If you are staying for a couple of days you might think about enjoying Lucca - or Pisa- during the morning and heading there after lunch later in the day rather than midmorning. The crush of crowds should already be there making the train trip easier and you'll arrive after check-in time at your hotel. Then you can enjoy CT as the day trippers leave and evening starts since early morning and evenings are when it will be most pleasant.
Playing Devil's advocate I would even suggest exploring the area around CT during the crush of the day trippers and then returning the in the afternoon. You could go north to Chiavari or other coastal Ligurian towns or explore the south side of La Spezia bay by taking the train - or early morning ferry against traffic - into La Spezia and bus down the coast to San Terenzo and then walk down and explore Lerici.
Have a great trip,
=Tod