How to write a recommendation letters for an undergrad student applying to transfer to another university?
A letter for undergraduate admissions need not be long.  Just write what you know about the student.  Since you had him in a course, you can mention his grade and (more helpfully) where he ranked among the students in the course.  Did he ask insightful questions?  Write especially clear solutions? If not, that's fine -- just say what you know.

Since you have spoken with him at length, you can probably also comment on his personality.  Is he easy-going and likeable?  Intensely passionate about his ideas?  Thoughtful and organized?

If you would be sorry to see him leave your program, say so and explain why.