Terminator 3: Terminator Dreams is a 2003 novel by Aaron Allston.
Before Judgment Day, Danny Avila helped to program what became Skynet and was plagued by nightmares of Terminators destroying cities and decimating mankind. He disappeared two days before Judgment Day, and didn't resurface until Kate and John discovered him years later. Danny still can't remember what happened to him just before Skynet attacked.
He has this nagging feeling that he has forgotten something very important. Despite this memory lapse, he has become a vital member of the Resistance.
Horrible dreams have begun to haunt him again. Could these dreams be a psychic link to his past self? John Connor has an idea: If Danny past and present can communicate, perhaps they can help the Resistance gain an edge and defeat Skynet. But to accomplish such a connection would place Danny at tremendous physical and emotional risk. It's a dangerous experiment, but one that might prove the salvation of mankind's future... and the death of Danny.