The fastest and safest way to clear up space is delete all render files. That’s done via File>Delete Generated Library Files>Delete Render Files>All. That does not delete optical flow or analysis files, which sometimes can be large.
Another approach is copy the project to a new library which will bring along just the media for that project timeline. You will be presented with a dialog about what media to copy.
You can determine which files are unused by your current project timeline by using the filter “unused media”, ie unused from the standpoint of the currently open timeline.
For any such cleanup work like this, it’s vital to *first* have a clear picture of where the media files are — internal to the library, or external and if so on what drive.
Imported files in FCP can either be copied within the library or with “leave files in place”. For “copy to library” files, deleting those within FCP will delete the media file from within the library, provided there are no other references to the file, ie no other timelines using it.
For external media imported with “leave files in place”, FCP will not delete those files. You must determine which are unused within FCP, make a list then delete those in FCP and use Finder to delete them on disk. Unfortunately there is no easy way to show which files are in each category.
Your best solution is getting the 3rd-party utility Final Cut Library Manager. It can safely delete all render, analysis and optical flow files across multiple libraries. It also has an optional feature to export a media list in .csv format showing the pathname to each file. That .csv file can help assess where your media is and how to handle it.