What is the standard way to measure contig sequence lengths in a BAM?
My understanding is that the community would use samtools idxstats to compute this information from the corresponding index file.
Are there more precise/standard approaches?
Standard approaches would be either samtools idxstats or samtools view -H, both of which will produce the exact same results. In fact, all methods will produce the exact same result, since contig length is set by the reference you align against.